Forum Moderators: coopster

Message Too Old, No Replies

Beginner question

         

1goodpuppy

12:46 am on Dec 2, 2003 (gmt 0)

10+ Year Member



I have set up apache and PHP 4 on my machine. My form scripts will not carry the values for the Variables over. It doesn't matter wether I use Get or post, I get the same error :

Notice: Undefined variable: YourName in c:\apache\apache\htdocs\bad_words.php on line 8

Any help would be greatly appreciated.

Eric

Timotheos

1:26 am on Dec 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi 1goodpuppy,

Are you referencing the post variables as $_POST['myvariable']?

Otherwise it might help if you let us see what is on line 8.

Tim

coopster

1:56 am on Dec 2, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I'm sure Timotheos is right, you are going to want to learn about Register Globals [php.net]. Have a look at this thread regarding Clarification of Global Variables OFF [webmasterworld.com].

1goodpuppy

5:08 am on Dec 2, 2003 (gmt 0)

10+ Year Member



Line 8: Hi <?php print $YourName;?>

Very simple script. As I said, I am just learning. This form Script is from a tutorial I am doing.

Could you Dumb it down for me? Am I using an old tutorial?

daosmith

5:59 am on Dec 2, 2003 (gmt 0)

10+ Year Member



Hi 1goodpuppy - your PHP setup probably has the register globals flag set to off (as suggested by coopster) - this means that if you are getting the $YourName variable from a form you will need to refer to it thus

$_POST['YourName'] if you use the POST method and
$_GET['YourName'] if you use the GET method.

I may be mistaken but I think the register globals flag used to be set to on automatically but that got changed somewhere around PHP 4. The effect of setting this flag to true is to allow you to use $YourName instead of one of the above two references, but it is normally better to use the longer notation above.

1goodpuppy

3:23 am on Dec 3, 2003 (gmt 0)

10+ Year Member



Thanks, everyone.

That did the trick. Is there any other way besides a .htaccess file to turn that flag on?

daosmith

3:30 am on Dec 3, 2003 (gmt 0)

10+ Year Member



Hi again,

If you have installed PHP on your home machine the register globals flag should be in your php.ini file somewhere; if this is set to true you can refer to your form variables without the $_POST and $_GET syntax.

However I suggest you take a look at this URL (which I hope the administrators don't mind if I post here) from the PHP site [au3.php.net ], before you decide to change it. Apparently there are a few security concerns with having the flag set to true.

Good luck with your PHP :)