Problem d'ajout

Fermé
reko - 20 mai 2009 à 21:42
ben85350 Messages postés 610 Date d'inscription vendredi 30 mai 2008 Statut Membre Dernière intervention 2 avril 2013 - 21 mai 2009 à 16:28
Bonjour,
vous pouvez m'aider j'ai un problem dans mon code quand je rempli les champs et je clic sur ajouter il me donne un nouveau formulaire pour nouvelle insertion mais quand je vérifie dans ma BD rien n'est insérer,


<?php

include("connexion.php");

?>

<CENTER><B><I><H2><FONT color=red><U> Ajouter Un Nouveau Etudiant </U></FONT></H2></I></B></CENTER>
<h4><u>Enter les informations suivantes puis appuyer sur le bouton<FONT color=purple>"Ajouter"</FONT></u></h4><br>
<form method="post" action ="ajouter.php" target="contenu" >
<table width=50% align=center cellspacing=10 cellpading=10 >

<tr><b>
<td>ID_Etudiant</td></b>
<td><input type="text" name="IDETUDIANT"></td></tr>
<tr><b>
<td>ID_Preinscription</td></b>
<td><input type="text" name="ID_PREINSCRIPTION"></td></tr>
<tr><b>
<td>ID_Concours</td></b>
<td> <input type="text" name="ID_CONCOURS"></td></tr>
<tr><b>
<td>Nom</td></b>
<td><input type="text" name="NOM"></td></tr>
<tr><b>
<td>Prénom</td></b>
<td> <input type="text" name="PRENOM"></td></tr>
<tr><b>
<td>Adresse </td></b>
<td><input type="text" name="ADRESSE"></td></tr>
<tr><b>
<td>Age</td></b>
<td><input type="text" name="AGE"></td></tr>
<tr><b>
<td>CIN</td></b>
<td><input type="text" name="CIN"></td></tr>
<tr><b>
<td>CNE</td></b>
<td><input type="text" name="CNE"></td></tr>
<td><input type="submit" value="Ajouter" name="commit" ></td>
</tr>
</table>
</form>

<?

if (isset($_POST['commit']))
{
//vérifier si l'utilisateur à saisi tous les champs du formulaire
if( (strnatcmp($_POST['IDEtudiant'],"")==0) || (strnatcmp($_POST['ID_Preinscription'],"")==0) || (strnatcmp($_POST['ID_Concours'],"")==0) || (strnatcmp($_POST['NOM'],"")==0)|| (strnatcmp($_POST['PRENOM'],"")==0)|| (strnatcmp($_POST['ADRESSE'],"")==0)|| (strnatcmp($_POST['AGE'],"")==0)|| (strnatcmp($_POST['CIN'],"")==0)|| (strnatcmp($_POST['CNE'],"")==0))
{
echo "<b><FONT color=red> veuillez remplir tous les champs!!!!!!!!</font></b>";
}

else
{
if( (isset($_POST['IDEtudiant'])) && (isset($_POST['ID_Preinscription'])) && (isset($_POST['ID_Concours'])) && (isset($_POST['NOM']))&& (isset($_POST['PRENOM']))&& (isset($_POST['ADRESSE']))&& (isset($_POST['AGE']))&& (isset($_POST['CIN']))&& (isset($_POST['CNE'])) )
{
$IDETUDIANT=$_post["IDETUDIANT"];
$ID_PREINSCRIPTION=$_post["ID_PREINSCRIPTION"];
$ID_CONCOURS=$_post["ID_CONCOURS"];
$NOM=$_post["NOM"];
$PRENOM=$_post["PRENOM"];
$ADRESSE=$_post["ADRESSE"];
$AGE=$_post["AGE"];
$CIN=$_post["CIN"];
$CNE=$_post["$CNE"];

$req1="SELECT * from etudiant where IDETUDIANT='$IDETUDIANT' ";
$res1=mysql_query($req1);
if(mysql_num_rows($res1)>0)
{
echo"<b><FONT color=purple> Numéro de l'etudiant déjà existe, veuillez saisir un autre identifiant !! </font></b>";
}
else{

$req="INSERT INTO etudiant (IDETUDIANT,ID_PREINSCRIPTION,$ID_CONCOURS,NOM,PRENOM,ADRESSE,AGE,CIN,CNE)
VALUES ('$IDETUDIANT', '$ID_PREINSCRIPTION', '$ID_CONCOURS', '$NOM','$PRENOM','$ADRESSE','$AGE','$CIN','$CNE')";
$res=mysql_query($req);
if(!$res)
{
echo "<b><FONT color=purple>Erreur pendant l'enregistrement du nouveau etudiant!!</font></b>";
}


else
{
echo "<b><FONT color=purple>Ajout effectué avec succés</font></b>";
}

}
};


}
}


?>

1 réponse

ben85350 Messages postés 610 Date d'inscription vendredi 30 mai 2008 Statut Membre Dernière intervention 2 avril 2013 27
21 mai 2009 à 16:28
salut !
vérifie d'abord que tu rentres bien dans ta boucle dans laquelle est ta requête.
sinon essai ceci :
$req="INSERT INTO etudiant (IDETUDIANT,ID_PREINSCRIPTION,".$ID_CONCOURS.",NOM,PRENOM,ADRESSE,AGE,CIN,CNE)
VALUES ('".$IDETUDIANT."', '".$ID_PREINSCRIPTION."', '".$ID_CONCOURS."', '".$NOM."','".$PRENOM."','".$ADRESSE."','".$AGE."','".$CIN."','".$CNE."')"
0