Insertion de plusieurs cases a coché dans mysql avec php

Bonjour,
tout le monde
c'est ma toute premiere question sur les forums mais bon je vous passe les détails

je voudrais inséré plusieurs cases a coché dans une bd sql l'idée c'est un devis de site web
je vous fait part mon code:

<form method="post" action="#" enctype="multipart/form-data">
<input type="hidden" name="func" value="create" />
<table>
<input type="hidden" name="id_devis" value="" />
<tr><td>nom</td>
<td><input type="text" name="nom" size="50" value="" maxlength="200" /></td></tr>
<tr><td>prenom</td>
<td><input type="text" name="prenom" size="50" value="" maxlength="200" /></td></tr>
<tr><td>mail</td>
<td><input type="text" name="mail" size="50" value="" maxlength="200" /></td></tr>
<tr><td>gsm</td>
<td><input type="text" name="gsm" size="50" value="" maxlength="200" /></td></tr>
<tr><td>budget</td>
<td><select name="budget">';
<option value="-500">moin 500TND</option>
<option value="500-1000">500 - 1000 TND</option>
<option value="1000-1500">1000 - 1500 TND</option>
<option value="1500-3000">1500 - 3000 TND</option>';
}
$output.= '</select></td></tr>
<tr><td>type</td>
<td><select name="type">';
<option value="Statique">Statique</option>
<option value="Dynamique">Dynamique</option>
<option value="Catalogue">Catalogue</option>
<option value="E-commerce">E-commerce</option>
<option value="Application">Application</option>';
}
$output.= '</select></td></tr>
<tr><td>offre</td>
<td><select name="offre">';
<option value="Petites">Pack Petites entreprises</option>
<option value="Entreprises">Pack Entreprises</option>
<option value="Exportateur">Pack Exportateur</option>
<option value="Gold">Promo Gold</option>';
}
$output.= '</select></td></tr>
<tr><td>domaine</td>
<td><input type="checkbox" name="domaine" value="domaine+hebergement" />Achat Domaine + hébérgement<br />
<input type="checkbox" name="domaine" value="domaine tn" />achat domaine en .tn<br />
<input type="checkbox" name="domaine" value="hebergement" />Achat d'hebergements<br />
<input type="checkbox" name="domaine" value="rien" />j'ai ce qu'il faut<br /> </td>

</td></tr>
<tr><td>Charte graphique</td>
<td><input type="checkbox" name="graphique" value="complete" />compléte<br />
<input type="checkbox" name="graphique" value="rien" />deja existante<br />
<input type="checkbox" name="graphique" value="logo" />logo<br />
<input type="checkbox" name="graphique" value="papperasse" />papperasse<br />
<input type="checkbox" name="graphique" value="impressions" />impressions diverses<br /> </td>

</td></tr>
<tr><td>Fonctionalité</td>
<td><input type="checkbox" name="fonctions" value="actu" />Actualités en ligne<br />
<input type="checkbox" name="fonctions" value="gestion de contenus" />gestion de contenus<br />
<input type="checkbox" name="fonctions" value="newsletter" />newsletter<br />
<input type="checkbox" name="fonctions" value="FAQ" />foire aux questions<br />
<input type="checkbox" name="fonctions" value="sondages" />sondages<br />
<input type="checkbox" name="fonctions" value="commerce sans payements" />E-commerce - (sans paiement sécurisé) <br />
<input type="checkbox" name="fonctions" value="commerce avec payements" />E-commerce - (avec paiement sécurisé) <br />
<input type="checkbox" name="fonctions" value="referencement naturel" />Référencement naturel<br />
<input type="checkbox" name="fonctions" value="référencement spécifique" />Référencement spécifique<br /> </td>

</td></tr>
<tr><td></td>
<td><input type="submit" value="creer" /></td></tr>
</table>
</form>
<?php
mysql_connect("localhost","root","");
mysql_select_db("tunaffaires");
?>
<?php

if (isset($_POST['nom'])){

$nom=$_POST['nom'];
$prenom=$_POST['prenom'];
$mail=$_POST['mail'];
$gsm=$_POST['gsm'];
$budget=$_POST['budget'];
$type=$_POST['type'];
$offre=$_POST['offre'];
$domaine=$_POST['domaine'];
$graphique=$_POST['graphique'];
$fonctions=$_POST['fonctions'];

$sql="INSERT INTO devis SET
nom='$nom',
prenom='$prenom',
mail='$mail',
gsm='$gsm',
budget='$budget',
type='$type',
offre='$offre',
domaine='$domaine',
graphique='$graphique',
fonctions='$fonctions';";

$Query1=mysql_query($sql) or die(mysql_error());
echo 'Vos infos on été ajoutées.';error_reporting(E_ALL);

}
?>

quelqu'un pourrais m'aidé SVP c super simple comme code

3 réponses

  1. Salut,

    Si on prend le cas des checkboxs pour la charte graphique, le noms des checkbox nommés "graphique" deviennent "graphique[]" :

    HTML:
    <input type="checkbox" name="graphique[]" value="rien" />deja existante<br /> 
    <input type="checkbox" name="graphique[]" value="logo" />logo<br /> 
    <input type="checkbox" name="graphique[]" value="papperasse" />papperasse<br /> 
    <input type="checkbox" name="graphique[]" value="impressions" />impressions diverses<br /> 


    PHP :
     
    //on déclare une variable
    $graphique ='';
    //on boucle
     for ($i=0;$i<count($_POST['graphique']);$i++)
        {
         //on concatène
          $graphique .= $_POST['graphique'][$i];
        }
    	echo $graphique;

    0
    1. bonjour tryan44 et merci de m'avoir répondu et merci de m'aidé :)

      je viens de tésté et sa m'a sorti array dans le champ que le service est supposé sortir
      j'ai peut etre fais un truc de traver :S
      0
      1. Voici un exemple tout simple testé en local et fonctionnel :

        <form method="post" id="monform" action="#">        
        <input type="checkbox" name="graphique[]" value="rien" />deja existante<br /> 
        <input type="checkbox" name="graphique[]" value="logo" />logo<br /> 
        <input type="checkbox" name="graphique[]" value="papperasse" />papperasse<br /> 
        <input type="checkbox" name="graphique[]" value="impressions" />impressions diverses<br />
        <input type="submit" name="valider" value="valider"> 
        </form>
        <?php
        if(isset($_POST['valider'])){
        //on déclare une variable
        $graphique ='';
        //on boucle
         for ($i=0;$i<count($_POST['graphique']);$i++)
            {
             //on concatène
              $graphique .= $_POST['graphique'][$i];
            }
        	echo $graphique;
        }
        ?>

        0