Hello everyone:
I am doing an exercise to retrieve data from form. I followed this example .
I didn't follow the exact coding order. I couldn't see the value for first_name text field.
Could you take a look at my code and tell me what I did wrong? Thanks!
<form method="post" action="<?php echo $PHP_SELF;?>">
First Name:<input type="text" size="12" maxlength="12" name="fname" /> <br />
Last Name:<input type="text" size="12" maxlength="36" name="lname" /> <br />
<!-- radio buttons and check boxes
radio button can have same name but different values
-->
Gender: <br />
Male <input type="radio" name="gender" value="male" /> <br />
Fale <input type="radio" name="gender" value="female" /> <br />
Please choose type of residence: <br />
Steak:<input type="checkbox" name="food[]" value="steak" /> <br />
Pizza:<input type="checkbox" name="food[]" value="pizza" /> <br />
Chicken:<input type="checkbox" name="food[]" value="chicken" /> <br />
Select level of education: <br />
<select name="education">
<option value="jrhigh">Junior High</option>
<option value="hischool">High School</option>
<option value="college">College</option>
</select>
<p><input type="submit" name="submit" value="submit" /></p>
</form>
<?php
$first_name = $_POST['fnmae'];
$last_name = $_POST['lname'];
$gender = $_POST['gender'];
$food = $_POST['food'];
$education = $_POST['education'];
if(!isset($_POST['submit']))
{ }
else
{
echo "Hello $first_name" . " $last_name" ."<br />";
echo "you are " . "$gender" . ", and you like ";
foreach ($food as $value)
echo $value . "<br />";
echo "you education is " . $education;
}
?>
Jeff
12-7-06