Forum Moderators: coopster

Message Too Old, No Replies

Full URL Address in a variable

How to get URL Address in a variable

         

fastfriend

10:29 am on Jan 19, 2006 (gmt 0)

10+ Year Member



I have a website where I invite people to write a review about a product. When a person wants to write a review, I ask him either for LOGIN or REGISTRATION, after successful LOGIN or REGISTRATION, I want him to show the page where he was before the LOGIN or Registration.

Let say my URL address looks like this

"http://www.anydomainnamexyz.com/directory/hardware/product.php?pid=1&brand=Imate&model=Jam&ram=64"

I am confused how to catch the whole URL into a single variable called $page_back, so I can send back the user to the above page after successful LOGIN or REGISTRATION.

dreamcatcher

11:02 am on Jan 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$page_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . ($_SERVER['QUERY_STRING']? '?'. $_SERVER['QUERY_STRING'] : '');

echo $page_url;

dc

coopster

3:04 pm on Jan 19, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, fastfriend.

You can also build the protocol portion of that string on the fly, just in case they were trying to enter a secured area:

$http = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '') . '://';

You could use that portion to replace the hard-coded 'http' part of dc's code.

dreamcatcher

6:37 pm on Jan 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks coop, forgot about secure urls. :)

fastfriend

9:51 am on Jan 20, 2006 (gmt 0)

10+ Year Member



Many thanks to all guys n gals.