-
Oct 24, 2002, 04:05 PM
#1
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.
-
Oct 24, 2002, 06:04 PM
#2
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.
-
Oct 25, 2002, 09:51 AM
#3
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.
-
Oct 25, 2002, 10:25 AM
#4
Re:PHP: Please Help Please
Nope, no luck. I wonder if I missed something in the .ini file.
Thanks again.
-
Oct 26, 2002, 03:58 PM
#5
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.
-
Oct 28, 2002, 05:05 PM
#6
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.
-
Oct 29, 2002, 02:18 PM
#7
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?
-
Oct 30, 2002, 12:37 PM
#8
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.
-
Oct 30, 2002, 04:29 PM
#9
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
-
Oct 31, 2002, 08:33 AM
#10
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
-
Forum Rules