Results 1 to 27 of 27

Thread: If (!$a) - undefined index [resolved]

Threaded View

  1. #1

    Thread Starter
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090

    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.
    Last edited by Acidic; Apr 2nd, 2004 at 10:31 AM.
    Have I helped you? Please Rate my posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width