ndisdabest Posted October 6, 2006 Share Posted October 6, 2006 Hi all --Easy question, I'm sure... and I'm guessing it's probably on the board somewhere, but I don't know what to look for, so I'll ask.I'm looking to grab all HTTP information (URL Referrals, Variables, Querystrings, etc) that comes along with a hit to my page. I did this with some simple code once before, but I don't remember what it is.Any help would be greatly appreciated!Thanks! Quote Link to comment Share on other sites More sharing options...
printf Posted October 6, 2006 Share Posted October 6, 2006 just use...[code]print_r ( $_SERVER );[/code]To see what you want to use, or you can do this to loop each one so you know each name value pair![code]<?echo '<pre>';foreach ( $_SERVER AS $name => $value ){ if ( $name == 'ALL_HTTP' ) { echo "\t\$_SERVER['" . $name . "'] = array ( \r\n"; $value = preg_split ( "/\r?\n/", $value, -1, PREG_SPLIT_NO_EMPTY ); foreach ( $value AS $all ) { echo "\t\t\$_SERVER['" . substr ( $all, 0, strpos ( $all, ':' ) ) . "'] = '" . substr ( $all, ( strpos ( $all, ':' ) + 1 ) ) . "';\r\n"; } echo "\t};\r\n"; } else { echo "\$_SERVER['" . $name . "'] = '" . $value . "';\r\n"; }}echo '</pre>';?>[/code]me! Quote Link to comment Share on other sites More sharing options...
ndisdabest Posted October 6, 2006 Author Share Posted October 6, 2006 That is great code... however, I am looking to grab information about the page the users are coming FROM. Any way to do this?Thanks again for all your help! Quote Link to comment Share on other sites More sharing options...
trq Posted October 6, 2006 Share Posted October 6, 2006 What infomation exactly? Nothing is passed from one page to another, they are completely seperate requests. Quote Link to comment Share on other sites More sharing options...
printf Posted October 6, 2006 Share Posted October 6, 2006 I put that example so you can see what you want to grab, so say you want the IP, REFERER (if referer), QUERY STRING, you use any of the $_SERVER variables to get that information![code]<?$ip = $_SERVER['REMOTE_ADDR'];$referer = ( ! empty ( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '' );$user_agent = $_SERVER['HTTP_USER_AGENT'];$query_string = ( ! empty ( $_SERVER['QUERY_STRING'] ) ? $_SERVER['QUERY_STRING'] : '' );?>[/code]me! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.