PHP

Forms

This form:
<form action="someform.php" method="GET">
Name: <input type="text" name="Name" value="Jim" /><br />
Password: <input type="password" name="Password" maxlength="10" /><br />
Age range: <select name="Age">
<option value="Under 16">Under 16</option>
<option value="16-30" SELECTED>16-30</option>
<option value="31-50">31-50</option>
<option value="51-80">51-80</option>
</select><br /><br />
Life story:<br /> <textarea name="Story" rows="10" cols="80">Enter your life story here</textarea><br /><br />
<input type="radio" name="FaveSport" value="Tennis"> Tennis</input>
<input type="radio" name="FaveSport" value="Cricket"> Cricket</input>
<input type="radio" name="FaveSport" value="Baseball"> Baseball</input>
<input type="radio" name="FaveSport" value="Polo"> Polo</input>
<br />
<input type="checkbox" name="Languages[]" value="PHP" CHECKED> PHP</input>
<input type="checkbox" name="Languages[]" value="CPP"> C++</input>
<input type="checkbox" name="Languages[]" value="Delphi"> Delphi</input>
<input type="checkbox" name="Languages[]" value="Java"> Java</input>
<br /><input type="submit" />
</form>
would be handled with:
<?php
   $_GET['Languages'] = implode(', ', $_GET['Languages']);
   $_GET['Story'] = str_replace("\n", "<br />", $_GET['Story']);

   print "Your name: {$_GET['Name']}<br />";
   print "Your password: {$_GET['Password']}<br />";
   print "Your age: {$_GET['Age']}<br /><br />";
   print "Your life story:<br />{$_GET['Story']}<br /><br />";
   print "Your favourite sport: {$_GET['FaveSport']}<br />";
   print "Languages you chose: {$_GET['Languages']}<br />";
?>

José M. Vidal .

29 of 33