Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

From which page came the user? 1

Status
Not open for further replies.

gizmicek

Programmer
Joined
Jun 25, 2003
Messages
107
Location
CZ
Hello,
I'd like to know if there is any way how to find out the page from which the user came to my pages. I have the chat service for logged users on my pages and the chat runs in separate browser window. Users come to chat service from my pages and I don't want the users to come from any other sites because they can simulate the login form (which is actually made only from hidden inputs containing username and password information and the submit button) and break the security. In general I want only know if there is a way how to find out that the user came to the pages eg. from so I can redirect him to the "Access Denied" page if he come from any other site ;-)

Any suggestions?
 
try this:
echo($HTTP_SERVER_VARS['REMOTE_ADDR']); in the page u want to protect. does it give the coorect address?

Known is handfull, Unknown is worldfull
 
You can use $_SERVER['HTTP_REFERER'] if the page was accessed through a link. Make it to be the required entry page and redirect all other accesses to whatever URL you'd like (Access denied... or You reached the page in a disallowed manner. Please use etc.)

I believe you have a newer PHP version, So $_SERVER should be fine.

Also:
If you don't want search robots to index the page use a <META> robots tag that says noindex.
 
>DRJ478
Thanx very much, its exactly what I need and it works perfectly! ;-)
 
gizmicek:
Just make sure that your code will behave correctly if $_SERVER['HTTP_REFERER'] is not available. A lot of web browsers allow the user to turn off referer reporting, so it is not guaranteed that the variable will be there.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
>sleipnir214
Thanks for the note. In fact I need to know where the user came from so if he turns the referer reporting off in his browser, he will see the error message &quot;Page referenced from untrasted site!&quot; instead of correct page and most likely will ask for this on my forum so this will be enough for me at the moment...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top