Forum Moderators: coopster

Message Too Old, No Replies

Trouble getting a URL variable to pass in PHP.

php variable

         

webwit

1:39 pm on Feb 8, 2004 (gmt 0)

10+ Year Member



I have two different Plesk 6 severs, both running Red Hat. I can't get a script to work on one that works on the other, then I realized the variables in the URL's were not passing, so I made a test script.

<HTML>
<HEAD>
<TITLE>test</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<?
echo "$title <br>";
echo "$title <br>";
echo "$title <br>";
?>
</BODY>
</HTML>

Then I type the URL test.php?title=this is a test

Then "this is a test" is printed on the screen 3 times.
Yet, on the other server this does nothing.

Is there a setting on my server I have to adjust for this, because the rest of the script works fine.

If so, how do you adjust the server settings to pass variables in the URL?

Thanks! :)

Knowles

1:52 pm on Feb 8, 2004 (gmt 0)

10+ Year Member



I *think* this has something to do with global variables [us4.php.net] being turned off. If you add $title = $HTTP_GET_VARS['title']; above the first echo title it will then GET the $title from the URL string. To verify that is what the issue is I would suggest taking a look at phpinfo() for both sites to see if they are turned on on one and turned off on the other.

webwit

1:32 am on Feb 9, 2004 (gmt 0)

10+ Year Member



Thank You Knowles!

You were correct.

I turned
register_globals = On
in my php.ini file.

Now it works great.

Thanks again!

Knowles

2:51 am on Feb 9, 2004 (gmt 0)

10+ Year Member



I think they may have turned that off by default for a reason. I am to lazy to look it up right now but I think it was a security hole. You may want to try and find away to do what you are needing too without using that feature.

roitracker

4:24 am on Feb 9, 2004 (gmt 0)

10+ Year Member



Due to potential security issues, register_globals is off by default in v4.2:

When on, register_globals will inject (poison) your scripts will all sorts of variables, like request variables from HTML forms...When on, people use variables yet really don't know for sure where they come from and can only assume.

You can do it this way: <? echo "$_GET['title']";?>