Hi I am beginner on learning PHP and i get some problem using $PHP_SELF.
I am praticing code from books and it looks like:
<?php
//$_POST retrieves our form data & outputs it directly to our browser.
$Fname=$_POST["Fname"];
$Lname=$_POST["Lname"];
$gender=$_POST["gender"];
$food=$_POST["food"];
$quote=$_POST["quote"];
$education=$_POST["education"];
$Tofd=$_POST["TofD"];
if(!ISSET($_POST['submit']))
{
//if page is not submitted to iteself echo the form
?>
<html>
<head>
<title>My Personla Info using $PHP_SELF</title>
</head>
<body>
<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="12" name="Lname" /><br/>
Gender:<br/>
Male:<input type="radio" value="Male" name="gender" /><br />
Female:<input type="radio" value="Female" name="gender" /><br />
Please Choose type of residence:<br />
Steak:<input type="checkbox" value="Steak" name="food[]" /><br />
Pizza:<input type="checkbox" value="Pizza" name="food[]" /><br />
Chicken:<input type="checkbox" value="Chicken" name="food[]" /><br />
<textarea rows="5" cols="20" name="quote" wrap="physical">
Enter your favorite quote!</textarea><br />
Select a Level of Education:<br />
<select name="education">
<option value="Secondary">Secondary</option>
<option value="HighSchool">HighSchool</option>
<option value="College">College</option><br />
</select>
Select your favorite time of day:<br />
<select name="TofD" size="3">
<option value="Morning">Morning</option>
<option value="Afternoon">Afternoon</option>
<option value="Night">Night</option>
</select>
<input type="submit" value="submit" name"submit" /><br />
</form><br />
<?php
}
else
{
echo "Hello, ".$fname. " " .$lname. ".<br>";
echo "You are ".$gender.", and you like ";
foreach ($food as $f)
{
echo $f."<br>";
}
echo "<i>".$quote."</i><br>";
echo "You're favorite time is ".$tofd.",and you passed".$education."</br>";
}
?>
</body>
</html>
it generate me the error message like this:
Notice: Undefined index: Fname in C:\wamp\www\test\myInfoForm.php on line 4
Notice: Undefined index: Lname in C:\wamp\www\test\myInfoForm.php on line 5
Notice: Undefined index: gender in C:\wamp\www\test\myInfoForm.php on line 6
Notice: Undefined index: food in C:\wamp\www\test\myInfoForm.php on line 7
Notice: Undefined index: quote in C:\wamp\www\test\myInfoForm.php on line 8
Notice: Undefined index: education in C:\wamp\www\test\myInfoForm.php on line 9
Notice: Undefined index: TofD in C:\wamp\www\test\myInfoForm.php on line 10
Need help to understand this.
Thank You