PHP: Comment valider les données d’un formulaire

Author:

 formulaire
Download

<?php
$choix = array('Janvier' => 'J',
                 'Fervier' => 'F',
                 'Mars' => 'M',
                 'Avril' => 'A');
if(isset($_POST['conges']))
{
// Vérifier si le choix posté par la variable '$_POST' corresponds à un élément du tableau
if (! array_key_exists($_POST['conges'], $choix))
{
    echo "<b>Aucun congé n'est attribué pour le mois choisi</b>";
}
else
{
 echo "<b>Votre choix à été enregistré</b>";
}
}
?>
 
<html>
 
  <head>
 
  </head>
 
  <body>
<form action ="<?php echo $_SERVER['PHP_SELF']; ?>" method = "post">
 
   Tapez votre nom complet:
<input type = "text" name = "nom">
 
   Tapez Le mois:
<input type = "text" name = "conges">
<input type = "submit" value = "evouyer">
   </form>
 
  </body>
</html>

Leave a Reply

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


× five = 20