If (!$a) - undefined index [resolved]
I have the following code:
PHP Code:
<?
$HTML1 = "You haven't filled in all the fields. I'll redirect you to my contact form in a couple more seconds.<script type='text/javascript'>function a() { location.href = 'contact.php' } window.setTimeout('a()',6000)</script>";
$HTML2 = "The mail was sent successfully. I'll redirect you to my index page now.<script type='text/javascript'>function a() { location.href = 'index.php' } window.setTimeout('a()',6000)</script>";
$HTML3 = "There has been an error posting the email, please try again.<script type='text/javascript'>function a() { location.href = 'contact.php' } window.setTimeout('a()',6000)</script>";
$a = $_POST['name'];
$b = $_POST['subject'];
$c = $_POST['body'];
if ((!$a) || (!$b) || (!$c))
{
//They have not filled in all fields Send them back
print $HTML1;
}
else
{
if (mail("[email protected]",$b,$c,"From " . $a))
{
print $HTML2;
}
else
{
print $HTML3;
}
}
?>
The page which sends the data has nothing wrong with it. Even if it did, this page is supposed to realise that.
When I run this, I always get:
Undefined index: name
Undefined index: subject
Undefined index: body
on lines 5,6 and 7. Which is where I make a variable equal them. What does error mean, what should I do to fix this?
edit:
after doing this, it prints $HTML1, even though I have filled in all the fields on the previous page.