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
| <?php
include ("connexion.php");
if(isset($_POST['submit1']))
{
$id = mysql_real_escape_string (htmlentities ($_POST['id']));
$nom = mysql_real_escape_string (htmlentities ($_POST['nom']));
$prenom = mysql_real_escape_string (htmlentities ($_POST['prenom']));
$age = mysql_real_escape_string (htmlentities ($_POST['age']));
if (($id<>'') AND ($nom<>'') AND ($prenom<>'') AND ($age<>''))
{
$goal = mysql_query ("SELECT * FROM troncon WHERE nom='$nom'");
$dada = mysql_num_rows($goal);
if($dada==0)
{
mysql_query ("INSERT INTO troncon VALUES ('$id', '$nom', '$prenom', '$age')");
die (" <br/>Les données saisies ont été bien enregistrées.");
} else "Cet identifiant existe déjà dans la BD !!! ";
}else echo "Veuillez renseigner tous les champs SVP.";
}
?>
<?php
//
$colonne=5;
$nb = $colonne-1; //Nombre de colonne
?>
<form action="enregistrement.php">
<table border="2" align="center">
<tr>
<th>ID</th>
<?php
for($i=0; $i<=$nb; $i++)
{
echo '<td><input type="text" name="id"/></td>';
}
?>
</tr>
<tr>
<th>NOM</th>
<?php
for($i=0; $i<=$nb; $i++)
{
echo '<td><input type="text" name="nom"/></td>';
}
?>
</tr>
<tr>
<th>PRENOM</th>
<?php
for($i=0; $i<=$nb; $i++)
{
echo '<td><input type="text" name="prenom"/></td>';
}
?>
</tr>
<tr>
<th>AGE</th>
<?php
for($i=0; $i<=$nb; $i++)
{
echo '<td><input type="text" name="age"/></td>';
}
?>
</tr>
</table>
<input type="submit" value="envoyer !" />
</form> |
Partager