// fichier : index.php(contient l'exemple du formulaire)
<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<title>Formulaire HTML</title>
</head>
<body>
<H2 align="center"><Font color="blue">User Registratiobn Form</Font></H2>
<fieldset>
<legend align = "center"><b>FORMULAIRE</b></legend>
<table width="400" border="1" align="center" cellpadding="5" cellspacing="0" bgcolor="#00CCFF">
<form name="registration" method="post" action="confirm.php" enctype="multipart/form-data">
<tr>
<td width="47%" align="center">Full Name</td>
<td colspan="2">
<input type="text" name="name" size="25" maxlenght="25"></td>
</tr>
<tr>
<td align="center" width="47%" Height="57">Address</td>
<td height="57" colspan="2">
<textarea name="Address" cols="26" rows="4"></textarea></td>
</tr>
<tr>
<td align="center" width="47%">Email</td>
<td height="2" colspan="2">
<input type="text" name="email" size="25" maxlenght="50"></td>
</tr>
<tr>
<td align="center" width="47%">Password</td>
<td height="2">
<input type="password" name="pass" size="25" maxlenght="15"></td>
</tr>
<tr>
<td align="center" width="47%">Confirm password</td>
<td height="2">
<input type="password" name="cpass" size="25" maxlenght="15"></td>
</tr>
<tr>
<td align="center" width="47%">Date of Birth</td>
<td height="2">
<select name="birth_month">
<option selected value=1>January
<option value=2>February
<option value=3>March
<option value=4>April
<option value=5>May
<option value=6>June
<option value=7>July
<option value=8>August
<option value=9>September
<option value=10>October
<option value=11>November
<option value=12>December
</ortion>
</select>
<select name="birth_day">
<option selected value=01>01
<option value=02>02
<option value=03>03
<option value=04>04
<option value=05>05
<option value=06>06
<option value=07>07
<option value=08>08
<option value=09>09
<option value=10>10
<option value=11>11
<option value=12>12
<option value=13>13
<option value=14>14
<option value=15>15
<option value=16>16
<option value=17>17
<option value=18>18
<option value=19>19
<option value=20>20
<option value=21>21
<option value=22>22
<option value=23>23
<option value=24>24
<option value=25>25
<option value=26>26
<option value=27>27
<option value=28>28
<option value=29>29
<option value=30>30
<option value=31>31
</option>
</select>
<input type="number" name="year" size="6" maxlength="4"></td>
</tr>
<tr><td align="center" width="47%">Gender</td>
<td height="50">
<input type="radio" name="gender" value="M">Male
<input type="radio" name="gender" value="F">Female
</td></tr>
<tr>
<td width="47%">Please choose topics of interest</td>
<td height="57">
<input type="checkbox" name="fiction" value="1">Fiction
<input type="checkbox" name="horror" value="2">Horror<br>
<input type="checkbox" name="action" value="3">Action
<input type="checkbox" name="comedy" value="4">Comedy<br>
<input type="checkbox" name="thriller" value="5">Thriller
</td>
</tr>
<tr>
<td width="50%">Select hobbies<br><br>
(Select multiple choices by holding the ctrl key and clicking on them one by one)</td>
<td height="57">
<select name="hobbies[]" size="7" multiple>
<option value="Outdoor Sports">Outdoor Sports</option>
<option value="Adventure Sports">Adventure Sports</option>
<option value="Pop Music">Pop Music</option>
<option value="Rock Music">Rock Music</option>
<option value="Aggressive Music">Aggressive Music</option>
<option value="Photography">Photography</option>
</select></td>
</tr>
<tr><td colspan="2">
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="reset" value="Reset">
</td>
</tr>
</form>
</table>
</fieldset>
</body>
</html>
// fichier confirm.php
<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<title>Accusée de réception du Formulaire HTML</title>
</head>
<body>
<?php
#Listing traite-index.php
// verification name
if(strlen($name)>0)
{
if(strlen($name)>5&&strlen($name)<50)
{$name=stripslashes($name);
}
else
{echo"<b><p>Invalid name</p></b>";
}
}
else
{$name=NULL;
echo"<b><p>Vous avez oblié de saisir votre nom</p></b>";
}
// verification adress
if(strlen($Address)>0)
{
if(strlen($Address)>5&&strlen($Address)<50)
{$Address=stripslashes($Address);
}
else
{echo"<b><p>Invalid adress</b></p>";
}
}
else
{$Address=NULL;
echo"<b><p>Vous avez oubliée de saisir votre adresse</b></p>";
}
// verification email
$arobaz = strpos($email, "@");
if(strlen($email)>0)
{
if(strlen($email)>5&&strlen($email)<20)
{$email=stripslashes($email);
if($arobaz=='')
{
echo "<b>Votre email doit comporter un </b><b>'@'</b>";
}
}
else
{echo"<b><p>Invalid email</b></p>";
}
}
else
{$email=NULL;
echo"<b><p>Vous avez oubliée de saisir votre E-mail</b></p>";
}
//verification mot de passe
if(strlen($pass)>0)
{
if(strlen($pass)>5&&strlen($pass)<20)
{echo"<b><p>garde le pour toi seul!!!</b></p>";
}
else
{echo"<b><p>Invalid password!!!!</b></p>";
}
}
else
{$pass=NULL;
echo"<b><p>Vous avez oubliée de saisir votre password!!!!!</b></p>";
}
// verification confirmation
if(strlen($cpass)>0)
{
if(strlen($cpass)!=strlen($pass))
{echo"<b><p>invalid confirmation!!!</b></p>";
}
else
{echo"<b><p>!!!!!!!!!!!!!</b></p>";
if ($cpass!= $pass)
{echo"<b><p>!!!invalid confirmation!!!</b></p>";
}
}
}
else
{$pass=NULL;
echo"<b><p>Vous avez oubliée de saisir votre confirmation password!!!!!</b></p>";
}
//verification year
if(strlen($year)>0)
{
if(strlen($year)!=4)
{echo"<b><p>Invalid year</b></p>";
}
}
else
{$year=NULL;
echo"<b><p>Vous avez oublié de saisir votre année de naissence</b></p>";
}
// verification gender
if(isset($gender))
{
if($gender=="M")
{$message="<b><p>Bonjour Monsieur $name</b></p>";
}
elseif($gender=="F")
{$message="<b><p>Bonjour Madame $name</b></p>";
}
}
else
{$gender=NULL;
echo"<b><p>Vous avez oublié de saisir votre Genre</b></p>";
}
// verification checkbox
if(!empty ($fiction))
{echo"<b>1</b><br />";
}
if(!empty ($comedy))
{echo"<b>2</b><br />";
}
if(!empty ($action))
{echo"<b>3</b><br />";
}
if(!empty ($triller))
{echo"<b>4</b><br />";
}
if(!empty ($horror))
{echo"<b>5</b><br />";
}
// verification de choix multiple
if($hobbies= array("phography,Outdoor Sports,Adventure,Pop Music,Rock Music,Aggressive Music"))
{echo"<i>tu aime tous!!!!!!!!!</i>";
}
// coclusion
if($name && $Address && $email && $pass&&$cpass && $year && $gender )
{ echo "<b>$message</b>";
echo"<tt> Mérçi, pour votre inscription </tt> <br /> <p>nous allons repondre avotre adresse E-mail : <i>$email</i></p>";
}
?>
</body>
</html>