Bonjour,
J'ai fait un formulaire pour inséré des clients, il ya tout qui joue bien au niveau du formulaire mais quand j'appuie sur ajouter il ne m'insère rien.
Voilà mon code
<html>
<script language="javascript">
<!--
function na_open_window(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
toolbar_str = toolbar ? 'yes' : 'no';
menubar_str = menubar ? 'yes' : 'no';
statusbar_str = statusbar ? 'yes' : 'no';
scrollbar_str = scrollbar ? 'yes' : 'no';
resizable_str = resizable ? 'yes' : 'no';
window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}
</script>
<?
include('erreur.lib.php');
include('connection.php');
if (isset($_POST['ajouter']) == 'ajouter')
{
if(isset($_POST['clinom']))
$nom = htmlspecialchars(htmlentities($_POST['clinom'], ENT_QUOTES));
//$nom = ucfirst($nom);
else
$nom="";
if(isset($_POST['clipre']))
$prenom = htmlspecialchars(htmlentities($_POST['clipre'], ENT_QUOTES));
//$prenom = ucfirst($prenom);
else
$prenom="";
if(isset($_POST['cliadr']))
$adresse = htmlspecialchars(htmlentities($_POST['cliadr'], ENT_QUOTES));
else
$adresse ="";
if(isset($_POST['clinpa']))
$npa = htmlspecialchars(htmlentities($_POST['clinpa'], ENT_QUOTES));
else
$npa ="";
if(isset($_POST['cliloc']))
$loc = htmlspecialchars(htmlentities($_POST['cliloc'], ENT_QUOTES));
else
$loc ="";
if(isset($_POST['clitel']))
$tel = htmlspecialchars(htmlentities($_POST['clitel'], ENT_QUOTES));
else
$tel ="";
if(isset($_POST['climob']))
$mob = htmlspecialchars(htmlentities($_POST['climob'], ENT_QUOTES));
else
$mob ="";
if(isset($_POST['clidatenais']))
$datenaissance = htmlspecialchars(htmlentities($_POST['clidatenais'], ENT_QUOTES));
else
$datenaissance ="";
if(isset($_POST['clinumide']))
$numidentite = htmlspecialchars(htmlentities($_POST['clinumide'], ENT_QUOTES));
else
$numidentite ="";
if(isset($_POST['climdp']))
$motpasse = htmlspecialchars(htmlentities($_POST['climdp'], ENT_QUOTES));
else
$motpasse ="";
if(isset($_POST['clinum_est_parraine']))
$cliparraine = htmlspecialchars(htmlentities($_POST['clinum_est_parraine'], ENT_QUOTES));
else
$cliparraine ="";
if(isset($_POST['clicom']))
$clicom = htmlspecialchars(htmlentities($_POST['clicom'], ENT_QUOTES));
else
$clicom ="";
if ( (!empty($clinom)) && (!empty($clipre)) && (!empty($cliadr)) && (!empty($clinpa)) && (!empty($cliloc)) && (!empty($clidatenais)) && (!empty($clinumide)) && (!empty($climdp)))
{
$sql = "INSERT INTO `client` (``,`clinum_est_parraine`,`clinom`, `clipre`, `cliadr`, `clinpa`, `cliloc`, `clitel`, `climob`, `clidatenais`,`clinumide`,`climdp`,`clicom`) VALUES ('','$cliparraine','$nom', '$prenom', '$adresse', '$npa', '$loc', '$tel', '$mob', '$datenaissance','$numidentite','$motpasse','$clicom')";
mysql_query($sql) or die ($errReq);
$id = mysql_insert_id();
echo "<div align='center'>";
echo "Le client a bien été inséré!";
?>
<form action="?ajoutcontrat" method="post">
<input type="submit" name="contrat" value="contrat" />
<input type="hidden" name="clinum" value="<?=$id ?>">
</form>
<?
echo "</div>";
mysql_close();
}
else
{
?>
<form action="ajoutcli.php" method="post">
<b class="rouge">Les champs avec * doivent être renseignés</b>
<fieldset>
<label for="nom"><?if ($nom == "" ){?><b class="rouge">Nom:</b><?}else{?>Nom<b class="rouge">*</b>:<?}?></label>
<input type="text" id="nom" value="<? echo $_POST['clinom']; ?>" name="clinom" size="40" maxlength="30"><br />
<label for="prenom"><?if ($prenom == "" ){?><b class="rouge">Prénom:</b><?}else{?>Prénom<b class="rouge">*</b><?}?></label>
<input type="text" id="prenom" value="<? echo $_POST['clipre']; ?>" name="clipre" size="40" maxlength="30"><br />
<label for="adresse"><?if ($adresse == "" ){?><b class="rouge">Adresse:</b><?}else{?>Adresse<b class="rouge">*</b><?}?></label>
<input type="text" id="adresse" value="<? echo $_POST['cliadr']; ?>" name="cliadr" size="60" maxlength="60"><br />
<label for="npa"><?if ($npa == "" ){?><b class="rouge">NPA:</b><?}else{?>NPA<b class="rouge">*</b>:<?}?></label>
<input type="text"id="npa" name="clinpa" value="<? echo $_POST['clinpa']; ?>" size="4" maxlength="4"><br />
<label for="loc"><?if ($loc == "" ){?><b class="rouge">Localité:</b><?}else{?>Localité<b class="rouge">*</b>:<?}?></label>
<input type="text" id="loc" name="cliloc" value="<? echo $_POST['cliloc'];?>" size="40" maxlength="30"><br />
<label for="tel"><?if ($tel == "" ){?><b class="rouge">Téléphone:</b><?}else{?>Téléphone<b class="rouge">*</b>:<?}?></label>
<input type="text" id="tel" name="clitel" value="<? echo $_POST['clitel']; ?>" size="15" maxlength="15"><br />
<label for="mob">Mobile:</label>
<input type="text" id="mob" name="climob" size="15" maxlength="15"><br />
<label for="datenaissance"><?if ($datenaissance == "" ){?><b class="rouge">Date de naissance:</b><?}else{?>Date de naissance<b class="rouge">*</b>:<?}?></label>
<input type="text" id="datenaissance" name="clidatenais" value="00-00-0000" size="10" maxlength="10"><br />
<label for="numidentite"><?if ($numidentite == "" ){?><b >Numéro carte d'identité:</b><?}else{?>Numéro carte d'identité<b class="rouge">*</b>:<?}?></label>
<input type="text" id="numidentite" name="clinumide" value="<? echo $_POST['clinumide']; ?>" size="9" maxlength="9"><br />
<label for="motpasse"><?if ($motpasse == "" ){?><b class="rouge">Mot de passe:</b><?}else{?>Mot de passe<b>*</b>:<?}?></label>
<input type="text" id="motpasse" name="climdp" value="<? echo $_POST['climdp']; ?>" size="20" maxlength="20"><br />
<label for="cliparraine">Numéro client parrainage:</label>
<input type="text" id="cliparraine" name="clinum_est_parraine" size="10" maxlength="10" value="<? PRINT($_POST[clinumparraine]);?>">
<a href="javascript:na_open_window('Trouverclient', 'parrainage.php', 0, 0, 500, 400, 0, 0, 0, 1, 1)" <input type="submit" name="Trouverclient" value="Trouverclient" /><br /></a>
<label for="clicom">Commentaire:</label>
<TEXTAREA type="text" id="clicom" name="clicom" size="300" value="<? echo $_POST['clicom']; ?>" maxlength="300"></TEXTAREA><br />
</fieldset>
<fieldset>
<input type="submit" name="ajouter" value="ajouter" />
<input type="hidden" name="clinum" value="<?=$id ?>">
<input type="reset" value="Effacer" />
</fieldset>
</form>
<?
}
}
else
{
?>
<form action="ajoutcli.php" method="post">
<b>Les champs avec * doivent être renseignés</b>
<fieldset>
<label for="nom">Nom<b class="rouge">*</b></label>
<input type="text" id="nom" name="clinom" size="40" maxlength="30"><br />
<label for="prenom">Prénom<b class="rouge">*</b></label>
<input type="text" id="prenom" name="clipre" size="40" maxlength="30"><br />
<label for="adresse">Adresse<b class="rouge">*</b></label>
<input type="text" id="adresse" name="cliadr" size="60" maxlength="60"><br />
<label for="npa">NPA<b class="rouge">*</b></label>
<input type="text"id="npa" name="clinpa" size="4" maxlength="4" value="1200"><br />
<label for="loc">Localité<b class="rouge">*</b></label>
<input type="text" id="loc" name="cliloc" size="40" maxlength="30"><br />
<label for="tel">Téléphone<b class="rouge">*</b></label></td>
<input type="text" id="tel" name="clitel" size="15" maxlength="15"><br />
<label for="mob">Mobile</label>
<input type="text" id="mob" name="climob" size="15" maxlength="15"><br />
<label for="datenaissance">Date de naissance<b class="rouge">*</b></label>
<input type="text" id="datenaissance" name="clidatenais" value="00-00-1900" size="10" maxlength="10"><br />
<label for="numidentite">Numéro carte d'identité<b class="rouge">*</b></label>
<input type="text" id="numidentite" name="clinumide" size="9" maxlength="9"><br />
<label for="motpasse">Mot de passe<b class="rouge">*</b></label>
<input type="text" id="motpasse" name="climdp" size="10" maxlength="10"><br />
<label for="cliparraine">Numéro client parrainage</label>
<input type="text" id="cliparraine" name="clinum_est_parraine" size="10" maxlength="10" value="<?PRINT($_POST[clinumparraine]);?>">
<a href="javascript:na_open_window('Trouverclient', 'parrainage.php', 0, 0, 500, 400, 0, 0, 0, 1, 1)" <input type="submit" name="Trouverclient" value="Trouverclient" /><br /></a>
<label for="cliCom">Commentaire</label>
<TEXTAREA type="text" id="cliCom" name="clicom" size="300" maxlength="300"></TEXTAREA><br />
</fieldset>
<fieldset>
<input type="submit" name="ajouter" value="ajouter" />
<input type="hidden" name="clinum" value="<?=$id ?>">
<input type="reset" value="Effacer" />
</fieldset>
</form>
<?
}
?>
</html>