Bonjour,
Merci pour vos aides successives, j'ai pas réussi à résoudre le prblm suivant . je veux récupérer mes champs d'un formulaire pour les ajouter à ma table contrat. Pour le moment il n'y a rien de spécial, mais dans mes champs du formulaire j'ai 2 champs de type Date d'où je pense est parvenu l'erreur.
Je m'explique:
j'ai fait un test pour le champs de la date if (!empty) { traitement d'insertion} else {msg 2} donc c'est le msg2 qui a été affiché. ensuite j'ai essayé une 2 eme fois d'enlever le ! pour voir ce qui va se passer donc j'ai eu 3 messages d'erreur: Notice: Undefined index: nom_champs_date in D:\Program Files\EasyPHP-5.3.1\www\hbs\contrat.php on line 23

Notice: Undefined index: nom_champs_date2 in D:\Program Files\EasyPHP-5.3.1\www\hbs\contrat.php on line 24
Column count doesn't match value count at row 1
voilà le code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
if (empty($_POST[' nom_champs_date'])){
$nom=$_POST['nome'];
$ref=$_POST['refk'];
$dated=$_POST[' nom_champs_date'];
$datef=$_POST['nom_champs_date2'];
$prix=$_POST['prix'];
$adr=$_POST['adr'];
$sql="insert into contrat (date_debut ,date_fin ,montant, adresse_loge, nom_sct, ref_kios) values ('$dated', '$datef', '$prix', '$adr' '$nom', '$ref' )";
$result=mysql_query ($sql) or die (mysql_error());
if ($result)
{echo "<script>alert('operation reussite');</script>"; 
 }
 else { echo " erreur"; }
}
else { echo "abcdef";}
et voilà le formulaire
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<form name="contrat" method="post" action="">
  <table width="527" height="233" border="0">
    <tr>
      <td width="176">Nom entreprise </td>
      <td width="341"><input name="nome" type="text" style="font-family:Courier New;font-size:12px"/></td>
    </tr>
    <tr>
      <td>R&eacute;f&eacute;rence kiosque </td>
      <td><input name="refk" type="text" style="font-family:Courier New;font-size:12px" /></td>
    </tr>
    <tr>
      <td>Date début location</td>
      <td><input type="text" id="nom_champs_date" style="font-family:Courier New;font-size:12px" name="nom_champs_date" value="" />
        <a href="javascript:popupwnd('calendrier.php?idcible=nom_champs_date&langue=fr','no','no','no','yes','yes','no','50','50','450','280')" target="_self"><img src="calendrier.gif" id="Image1" alt="" align="top" border="0" style="width:26px;height:26px;" /></a></td>
    </tr>
    <tr>
      <td>Date fin location</td>
      <td><input type="text" id="nom_champs_date2" style="font-family:Courier New;font-size:12px" name="nom_champs_date" value="" />
        <a href="javascript:popupwnd('calendrier.php?idcible=nom_champs_date2&langue=fr','no','no','no','yes','yes','no','50','50','450','280')" target="_self"><img src="calendrier.gif" id="Image1" alt="" align="top" border="0" style="width:26px;height:26px;" /></a></td>
    </tr>
    <tr>
      <td>Prix</td>
      <td><input name="prix" type="text" style="font-family:Courier New;font-size:12px"/></td>
    </tr>
        <tr>
      <td>Adresse logement</td>
      <td><input name="adr" type="text" style="font-family:Courier New;font-size:12px"/></td>
    </tr>
    <tr>
      <td><input name="verifier" type="submit" value="v&eacute;rifier"/></td>
      <td>&nbsp;</td>
    </tr>
  </table>
</form>
Merci de m'aider