Bonjour,

j'ai un petit soucis avec un ajout dans la base de donnée qui m'affiche "Champs obligatoire non renseigne, ajout non possible !"

Je comprends pas trop car, la zone numero et nom ne sont pas vide donc cela devrait fonctionner ...

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php 
 
//importation du fichier qui contient les coordonn�es de connexion
include 'connexion.php';
 
 
 
$resultat = 0;
 
if (isset($_POST[btnajouter])) {
	$numero = $HTTP_POST_VARS["txtnumero"];
	$nom = $HTTP_POST_VARS["txtnom"];
	$prenom = $HTTP_POST_VARS["txtprenom"];
	$vehicule = $HTTP_POST_VARS["txtvehicule"];
        $etude = $HTTP_POST_VARS["txtetude"];
	$experience = $HTTP_POST_VARS["txtexperience"];
	$age = $HTTP_POST_VARS["txtage"];
	$datedispo = $HTTP_POST_VARS["txtdatedispo"];
        $ville = $HTTP_POST_VARS["txtville"];
 
 
	if (empty($prenom) or empty($numero)) {
		$resultat = -1;
	}
	else {
		$resultat = 1;
		mysql_query("INSERT INTO depotcv (numero, nom, prenom, vehicule, etude, experience, age, datedispo, ville) " 
                  . "values ('".$numero."', '".$nom."', '".$prenom."', '".$vehicule."', '".$etude."', '".$experience."', '".$age."', '".$datedispo."', '".$ville."')", $connexion)
             or $resultat = -2;
 
		//mysql_query("INSERT INTO direction VALUES codedir='".$code."', nomdir='".$nom."', contactdir='".$contact."', adressedir='".$adresse."' ", $connexion) 
			//or $resultat = -2;
	}
 
}
 
 
?>
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Ajout CV</title>
</head>
 
<body>
<table width="100%" height="482" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center" valign="top"><table width="551" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="600" height="57">&nbsp;</td>
      </tr>
    </table>
      <table width="648" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="475" height="57" align="center">Ajout de CV :  <strong><?php echo $nom ?></strong></td>
          <td width="76" align="right"><a href="direction_liste.php">Retour</a></td>
        </tr>
      </table>
      <table width="650" height="34" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
        <tr>
          <td height="34" align="center">
		  <?php 
		  switch ($resultat) {
		  	case 0:
		  		echo 'Renseignez les champs obligatoires avant de valider !';
				break;
			case 1:
				echo 'Ajout effectue avec succes !';
				break;
			case -1:
				echo 'Champs obligatoire non renseigne, ajout non possible !';
				break;
		  }
 
		  ?>
 
		  </td>
        </tr>
      </table>
      <form id="form1" name="form1" method="post" action="">
        <table width="459" height="188" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="149" align="left">Numero</td>
            <td width="310" align="left"><label>
              <input name="txtnumero" type="text" id="txtnumero" size="30"/>
            </label></td>
          </tr>
          <tr>
            <td align="left">Nom</td>
            <td align="left"><label>
            <input name="txtnom" type="text" id="txtnom" size="30"/>
            </label></td>
          </tr>
          <tr>
            <td align="left">Prenom</td>
            <td align="left"><input name="txtprenom" type="text" id="txtprenom" size="45" /></td>
          </tr>
          <tr>
            <td align="left">Vehicule</td>
            <td align="left"><input name="txtvehicule" type="text" id="txtvehicule" /></td>
          </tr>
            <tr>
            <td align="left">Etude</td>
            <td align="left"><input name="txtetude" type="text" id="txtetude" /></td>
          </tr>
            <tr>
            <td align="left">Experience</td>
            <td align="left"><input name="txtexperience" type="text" id="txtexperience" /></td>
          </tr>
            <tr>
            <td align="left">Age</td>
            <td align="left"><input name="txtage" type="text" id="txtage" /></td>
          </tr>
            <tr>
            <td align="left">Date disponibilité</td>
            <td align="left"><input name="txtdispo" type="text" id="txtdispo" /></td>
          </tr>
            <tr>
            <td align="left">Ville</td>
            <td align="left"><input name="txtville" type="text" id="txtville" /></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td align="left"><label>
              <input name="btnajouter" type="submit" id="btnajouter" value="Ajouter" />
            </label></td>
          </tr>
        </table>
      </form>
      <table width="650" height="34" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td height="34" align="left">&nbsp;</td>
        </tr>
      </table></td>
  </tr>
</table>
</body>
</html>