Web Hosting Talk







View Full Version : $_SERVER['PHP_SELF'] problem


kenfused
08-13-2003, 01:31 AM
Hello
I'm using PHP and $_SERVER['PHP_SELF'] to try to make a "next page" function.

For example
if my URL is

www.mysite.com/index.php?query=1&search=2&page=1

Using $_SERVER['PHP_SELF'] seems to only return

www.mysite.com/index.php?
without the accompanying existing query specifics information

Any idea why it's not getting the entire URL with the ?query=1&search=2 etc.?

Thanks

The Prohacker
08-13-2003, 01:54 AM
Check out: $_SERVER["REQUEST_URI"]

kenfused
08-13-2003, 02:03 AM
hmmm
seems to work, once.
But then my function appends ?page=2 to the URL every time, so the URL keeps growing... myurl/page=2page=2page=2, etc..

I mayhave to try another way

Rich2k
08-13-2003, 04:39 AM
write a regular expression to remove page=n from the query string.

I did one a while ago in cold fusion, I'll see if I can find it to re-write in php

tichuot
08-13-2003, 10:28 AM
$requestend = stripslashes(urldecode($_SERVER['QUERY_STRING']));

kenfused
08-13-2003, 10:55 AM
Thanks...
What does that last PHP code do?
Where should I put it?
Thanks!

Rich2k
08-13-2003, 12:17 PM
All it does is standard cleaning of a GPC variable. However you should really check whether magic_quotes_GPC is enabled before needing to run a stripslashes.

URLdecode happens automatically in PHP for GET variables and therefore you shouldn't run it again.

kenfused
08-13-2003, 02:16 PM
Hello
So I should add this line in once in the script before calling
$_server['php_self']

Thanks!

sorry for so many newbie questions!