To get previous page URL
Moderator: General Moderators
To get previous page URL
When people click and visit my website, i want to know where they come from. Just want to know their previous URL when visitor visit my website.
I try to use HttpRequest::getUrl ( ), but the information provided is not enough. So i don't know how to use it. Can this command do it? Anyway i can get previous URL?
I try to use HttpRequest::getUrl ( ), but the information provided is not enough. So i don't know how to use it. Can this command do it? Anyway i can get previous URL?
The condition is this. Said i have
page01.php
page02.php
page03.php
page04.php and so on......
page01.php - login page
page02.php - check login name to databasse and do many other stuff....
page03.php - after page02, then page02 will redirect to page03.php.......
page01.php and page03.php can be access direct without causing problem. But page02.php cannot be access directly without going through page01.php......or it will cause problem....
So in order for page02.php to check whether it;s from page01.php, page02.php need to check previous page that access to page02.php....That is why i am using http_referer.
Currently i am using session, everything is fine. but i feel problem with the session, where i need to set at page01.php.....
Any way $_SERVER['HTTP_REFERER'] can detect previous page if the previous page is using header("location:").
page01.php
page02.php
page03.php
page04.php and so on......
page01.php - login page
page02.php - check login name to databasse and do many other stuff....
page03.php - after page02, then page02 will redirect to page03.php.......
page01.php and page03.php can be access direct without causing problem. But page02.php cannot be access directly without going through page01.php......or it will cause problem....
So in order for page02.php to check whether it;s from page01.php, page02.php need to check previous page that access to page02.php....That is why i am using http_referer.
Currently i am using session, everything is fine. but i feel problem with the session, where i need to set at page01.php.....
Any way $_SERVER['HTTP_REFERER'] can detect previous page if the previous page is using header("location:").
feyd | Please use
page_02.php
=========[/syntax]
page_03.php
=========
page_04.php
=========
FINDING
======
If i want the sequence to be page01-->02-->03-->04, on 02 and 03 all i need to do is to check the http_referer equal to first page, which is page01.php.
The logic is here, if page is automatically going from 02 to 03 and 04, then all this file only need to check on page_01. Instead of 03 check on 02, and 04 check on 03...., all the 02,03,04 will check on 01 will do.
I have try to set highest security on the browser IE6 and using mozilla to test on the testing above, everything works fine...
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I have found something very interesting here, Said there is 4 page:
page_01.php
page_02.php
page_03.php
page_04.php
Below are the php file contents. Basically it's a test of :
page_01.php --> page_02.php --> page_03.php --> page_04.php
page_01.php
=========
[syntax="html"]<p>Page 1</p>
<p><a href="t2.php">Click Here</a></p>=========[/syntax]
Code: Select all
if ($_SERVER['HTTP_REFERER'] == "http://localhost/t1.php"):
header("location:t3.php");
else:
echo "wrong";
endif;page_03.php
=========
Code: Select all
header("location:t4.php");
if ($_SERVER['HTTP_REFERER'] == "http://localhost/t1.php"):
header("location:t4.php");
else:
echo "wrong";
endif;page_04.php
=========
Code: Select all
echo $_SERVER['HTTP_REFERER'];FINDING
======
If i want the sequence to be page01-->02-->03-->04, on 02 and 03 all i need to do is to check the http_referer equal to first page, which is page01.php.
The logic is here, if page is automatically going from 02 to 03 and 04, then all this file only need to check on page_01. Instead of 03 check on 02, and 04 check on 03...., all the 02,03,04 will check on 01 will do.
I have try to set highest security on the browser IE6 and using mozilla to test on the testing above, everything works fine...
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]