PHP: Stocker les données d’un formulaire dans un tableau

Author:

 formulaire
Download

<html>
<body>
<form method="post" action="<?php print $_SERVER['PHP_SELF'];?>">
<h1>Information Famille</h1>
<table>
<tr>
<td>Nom des Enfants:</td>
</tr>
<tr>
<td>
<input type="text" name="enfants[]"></td>
</tr>
<tr>
<td>
<input type="text" name="enfants[]"></td>
</tr>
<tr>
<td>
<input type="text" name="enfants[]"></td>
</tr>
<tr>
<td>
<input type="text" name="enfants[]"></td>
</tr>
<tr>
<td>
<input type="text" name="enfants[]"></td>
</tr>
</table>
 
 
<tr>
<td>
<input type="submit" value="submit"></td>
<td>
<input type="reset"  value="Effacer tout"></td>
</tr>
</form>
 
</body>
 
</HTML>
 
<?php
 
  if(isset($_POST['enfants']))
  {
foreach ($enfants as $index => $enfant){
    echo "enfant[$index]=$enfant";
}
echo "";
 
// Trier le tableau du formulaire
sort($enfants);
 
foreach ($enfants as $index => $enfant)
{
    echo "enfant[$index]=$enfant";
}
 
}
?>

Leave a Reply

Your email address will not be published. Required fields are marked *


8 × = sixteen