PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
guarriman
Forum Commoner
Posts: 44 Joined: Thu Nov 03, 2005 4:11 am
Post
by guarriman » Fri Jan 12, 2007 3:43 am
Hi.
Working with PHP4, I created this PHP file:
Code: Select all
<html>
<li>REFERER: <?echo $_SERVER['HTTP_REFERER'];?>
<li><a href=ie7-referer.php>Click here</a>
</html>
It works ok (it shows webpage refererer) with most of web browsers, but not with IE7 or Opera.
Does anybody know an alternative to HTTP_REFERER to know the webpage the user come from?
Thank you very much,
Kieran Huggins
DevNet Master
Posts: 3635 Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:
Post
by Kieran Huggins » Fri Jan 12, 2007 4:12 am
Please post the results of:
Copy and paste the code in, then the results out if you please.
Incidentally, it's technically considered bad practice to trust this particular variable. You may consider using a token of some sort instead.
guarriman
Forum Commoner
Posts: 44 Joined: Thu Nov 03, 2005 4:11 am
Post
by guarriman » Fri Jan 12, 2007 7:22 am
Code: Select all
Array ( [UNIQUE_ID] => qTMXt38AAAE37ApwEhcABAAJ [HTTP_ACCEPT] => image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */* [HTTP________] => ----:---------------------------------- [HTTP_ACCEPT_LANGUAGE] => en [HTTP_UA_CPU] => x86 [HTTP_ACCEPT_ENCODING] => gzip, deflate [HTTP_USER_AGENT] => Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1) [HTTP_HOST] => fooserver [HTTP_CONNECTION] => Keep-Alive [PATH] => /sbin:/usr/sbin:/bin:/usr/bin [SERVER_SIGNATURE] => Apache/2.0.11 (Unix) DAV/2 PHP/4.4.4 Server at fooserver Port 80 [SERVER_SOFTWARE] => Apache/2.0.11 (Unix) DAV/2 PHP/4.4.4 [SERVER_NAME] => fooserver [SERVER_ADDR] => 192.160.2.3 [SERVER_PORT] => 80 [REMOTE_ADDR] =>
2c9d:a138:48f6:a2bf:302f:5600:a00:0 [DOCUMENT_ROOT] => /home/www [SERVER_ADMIN] => webmaster@mydomain.com [SCRIPT_FILENAME] => /home/www/tests/ie7-referer.php [REMOTE_PORT] => 1371 [REMOTE_USER] => mydomain [AUTH_TYPE] => Basic [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => [REQUEST_URI] => /tests/ie7-referer.php [SCRIPT_NAME] => /tests/ie7-referer.php [PHP_SELF] => /tests/ie7-referer.php [PATH_TRANSLATED] => /home/www/tests/ie7-referer.php [PHP_AUTH_USER] => john [PHP_AUTH_PW] => xxx )
The script name is 'ie7-referer.php', and I like to get 'back.html' (the URL containing the link to 'ie7-referer.php').
Kieran Huggins
DevNet Master
Posts: 3635 Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:
Post
by Kieran Huggins » Fri Jan 12, 2007 7:30 am
can you post the source of that instead? It's a bit hard to read.
guarriman
Forum Commoner
Posts: 44 Joined: Thu Nov 03, 2005 4:11 am
Post
by guarriman » Fri Jan 12, 2007 9:17 am
Kieran:
Code: Select all
Array (
[UNIQUE_ID] => qTMXt38AAAE37ApwEhcABAAJ
[HTTP_ACCEPT] => image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*
[HTTP________] => ----:----------------------------------
[HTTP_ACCEPT_LANGUAGE] => en
[HTTP_UA_CPU] => x86
[HTTP_ACCEPT_ENCODING] => gzip, deflate
[HTTP_USER_AGENT] => Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)
[HTTP_HOST] => fooserver
[HTTP_CONNECTION] => Keep-Alive
[PATH] => /sbin:/usr/sbin:/bin:/usr/bin
[SERVER_SIGNATURE] => Apache/2.0.11 (Unix) DAV/2 PHP/4.4.4 Server at fooserver Port 80
[SERVER_SOFTWARE] => Apache/2.0.11 (Unix) DAV/2 PHP/4.4.4
[SERVER_NAME] => fooserver
[SERVER_ADDR] => 192.160.2.3
[SERVER_PORT] => 80
[REMOTE_ADDR] => 2c9d:a138:48f6:a2bf:302f:5600:a00:0
[DOCUMENT_ROOT] => /home/www
[SERVER_ADMIN] => webmaster@mydomain.com
[SCRIPT_FILENAME] => /home/www/tests/ie7-referer.php
[REMOTE_PORT] => 1371
[REMOTE_USER] => mydomain
[AUTH_TYPE] => Basic
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /tests/ie7-referer.php
[SCRIPT_NAME] => /tests/ie7-referer.php
[PHP_SELF] => /tests/ie7-referer.php
[PATH_TRANSLATED] => /home/www/tests/ie7-referer.php
[PHP_AUTH_USER] => john
[PHP_AUTH_PW] => xxx
)
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Jan 12, 2007 10:09 am
If the browser doesn't send it, you're stuck.
If you control the referring page you can use sessions, cookies or the URL to pass the information if you feel it's that vital. If it's absolutely vital, your only option is sessions. The other two can easily be removed.
bokehman
Forum Regular
Posts: 509 Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)
Post
by bokehman » Fri Jan 12, 2007 2:24 pm
guarriman wrote: Code: Select all
Array (
[HTTP________] => ----:----------------------------------
)Looks like the firewall/privacy software is blocking something there.