Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: PHP: Please Help Please

  1. #1
    Join Date
    Aug 2002
    Posts
    193
    Rep Power
    0

    Default PHP: Please Help Please

    Hey there u PHP ppl out there. I am just now getting into PHP and have started writing some stuff. For some reason tho' I have some code that just refuses to work. It is supposed to as u can tell post some input information to my PHP results page. For some reason I can't get this to happen it keeps giving me the message:

    "PHP Notice: Undefined variable: YourName in d:\www\speednet-jm.com\php_form.php on line 11 PHP Notice: Undefined variable: FavoriteWord in d:\www\speednet-jm.com\php_form.php on line 14 "


    I have included the code for both files. If u have any insight plz lemme know or lemme know if u think it is a server prob, and suggestions to a possible solution.

    File: form.htm
    <html>
    <head>
    <title>My Form</title>
    </head>
    <body>
    <form action="php_form.php" method=post>
    My name is:
    <br> <input type="text" name="YourName">
    <p> My favourite word is:
    <br> <input type="text" name="FavoriteWord">
    <p>
    <input type="submit" name="submit" value="Enter My Data!">
    </form>
    </body>
    </html>

    File: php_form.htm
    <html>
    <head>
    <title>Response!</title>
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <?php //$YourName="Omar D."; ?>
    <p>
    Hi <?php print $YourName; ?>
    <p>
    You like the word <b> <?php print $FavoriteWord; ?> !?! </b>
    <p>You oughta be ashamed of yourself!
    </body>
    </html>


    Thanks ppl. L8r.

  2. #2
    Join Date
    Jul 2002
    Posts
    5,446
    Rep Power
    10

    Default Re:PHP: Please Help Please

    I'm no pro PHP dev guy, I'm learning it myself, but two things pop out at me.

    1. You have method=post and I'm accustomed to using method="post".

    2. One of your files is named php_form.htm, however in form.htm you use form action="php_form.php". Rename the file to php_form.php.

    Hope this helps.


  3. #3
    Join Date
    Aug 2002
    Posts
    193
    Rep Power
    0

    Default Re:PHP: Please Help Please

    I'm no pro PHP dev guy, I'm learning it myself, but two things pop out at me.

    1. You have method=post and I'm accustomed to using method="post".
    I will check this out and let you know... thanks.

    2. One of your files is named php_form.htm, however in form.htm you use form action="php_form.php". Rename the file to php_form.php.
    Sorry, this was a typo on my part, the file is actually named php_form.php

    Hope this helps.


    Thanks again.

  4. #4
    Join Date
    Aug 2002
    Posts
    193
    Rep Power
    0

    Default Re:PHP: Please Help Please

    Nope, no luck. I wonder if I missed something in the .ini file.

    Thanks again.

  5. #5
    Join Date
    Jul 2002
    Posts
    818
    Rep Power
    0

    Default Re:PHP: Please Help Please

    I've run your code and I have received none of your errors.

    However, looking at the error message it's pretty straight forward. I'm guessing the reason I don't get the error and you do is that you have enabled full error reporting in you php.ini file.

    Could this be the case? If so try one of two things.

    1) Disable full error reporting.
    2) Declare your variables before using them.

  6. #6
    Join Date
    Aug 2002
    Posts
    193
    Rep Power
    0

    Default Re:PHP: Please Help Please

    Thanks, but decalring the variables before, didn't work. Now that I have turned off error reporting, I don't get the messages, but it still doesn't print the variable from the form. It just says "Hi".

    If however I declare the variable on the php action page then try to print it, that works fine.

    Thanks again.

  7. #7
    Join Date
    Jul 2002
    Posts
    818
    Rep Power
    0

    Default Re:PHP: Please Help Please

    [quote author=odsamuels link=board=10;threadid=208;start=0#1447 date=1035842701]
    Thanks, but decalring the variables before, didn't work.
    If however I declare the variable on the php action page then try to print it, that works fine.
    [/quote]

    Where exactly were you declaring them before?

  8. #8
    Join Date
    Aug 2002
    Posts
    193
    Rep Power
    0

    Default Re:PHP: Please Help Please

    Okay thanks guys, but I got it working. Just FYI I had to switch and use the $_POST array like this: Hi <?php echo $_POST["name"]; ?>. to get it to print the name field posted from the form.

    Thanks again.

  9. #9
    Join Date
    Jul 2002
    Posts
    5,446
    Rep Power
    10

    Default Re:PHP: Please Help Please

    Looks like I really need to START learning PHP instead of SAYING that I'm learning it :-[ Oh for more hours in the day ;D

  10. #10
    Join Date
    Jul 2002
    Posts
    818
    Rep Power
    0

    Default Re:PHP: Please Help Please

    odsamuels, send me a copy of your php.ini file. I'd like to review it.

Posting Permissions

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