inVINCEable Posted June 3, 2010 Share Posted June 3, 2010 I am checking referrers on a particular site, let's say domain.com/campaigns/2/ is where I am pointing them to. In there I have an index.php file that records the referrer as well as the request URL. Sometimes it is recorded correctly, such as "/campaigns/2/" and other times it comes up null. Either way they are hitting the file there, so what is the explanation as to why it would come up null? Thanks! Link to comment https://forums.phpfreaks.com/topic/203801-why-would-_serverrequest_uri-come-up-empty-or-null/ Share on other sites More sharing options...
mrMarcus Posted June 3, 2010 Share Posted June 3, 2010 Wow, your code is invisible. Oh wait...you didn't post any. Post the relevant code, even the db insert. Link to comment https://forums.phpfreaks.com/topic/203801-why-would-_serverrequest_uri-come-up-empty-or-null/#findComment-1067391 Share on other sites More sharing options...
inVINCEable Posted June 3, 2010 Author Share Posted June 3, 2010 Sorry, I didn't mean to say it is a DB insert, it just logs the info in a file. Here is the info: Here is the php: <?php //lets log visitor information $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; $query = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : ''; $request_method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : ''; $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''; $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $remote_host = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : ''; $remote_port = isset($_SERVER['REMOTE_PORT']) ? $_SERVER['REMOTE_PORT'] : ''; $request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; $agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; if(file_exists("info.txt")){ $file = fopen("info.txt", "a"); $info = "Referer: " . $referer . "\n\n"; $info .= "Query: " . $query . "\n\n"; $info .= "Request Method: " . $request_method . "\n\n"; $info .= "Host: " . $host . "\n\n"; $info .= "IP: " . $ip . "\n\n"; $info .= "Remote Host: " . $remote_host . "\n\n"; $info .= "Remote Port: " . $remote_port . "\n\n"; $info .= "Request URL: " . $request_uri . "\n\n"; $info .= "Agent: " . $agent . "\n\n"; $info .= "-----------------------------------------"; fwrite($file, $info); } else { $file = fopen("info.txt", "w"); $info = "Referer: " . $referer . "\n\n"; $info .= "Query: " . $query . "\n\n"; $info .= "Request Method: " . $request_method . "\n\n"; $info .= "Host: " . $host . "\n\n"; $info .= "IP: " . $ip . "\n\n"; $info .= "Remote Host: " . $remote_host . "\n\n"; $info .= "Remote Port: " . $remote_port . "\n\n"; $info .= "Request URL: " . $request_url . "\n\n"; $info .= "Agent: " . $agent . "\n\n"; $info .= "-----------------------------------------"; fwrite($file, $info); } ?> And here is the HTML file in its entirety: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Get My Email Guide</title> </head> <body> <?php //lets log visitor information $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; $query = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : ''; $request_method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : ''; $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''; $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $remote_host = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : ''; $remote_port = isset($_SERVER['REMOTE_PORT']) ? $_SERVER['REMOTE_PORT'] : ''; $request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; $agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; if(file_exists("info.txt")){ $file = fopen("info.txt", "a"); $info = "Referer: " . $referer . "\n\n"; $info .= "Query: " . $query . "\n\n"; $info .= "Request Method: " . $request_method . "\n\n"; $info .= "Host: " . $host . "\n\n"; $info .= "IP: " . $ip . "\n\n"; $info .= "Remote Host: " . $remote_host . "\n\n"; $info .= "Remote Port: " . $remote_port . "\n\n"; $info .= "Request URL: " . $request_uri . "\n\n"; $info .= "Agent: " . $agent . "\n\n"; $info .= "-----------------------------------------"; fwrite($file, $info); } else { $file = fopen("info.txt", "w"); $info = "Referer: " . $referer . "\n\n"; $info .= "Query: " . $query . "\n\n"; $info .= "Request Method: " . $request_method . "\n\n"; $info .= "Host: " . $host . "\n\n"; $info .= "IP: " . $ip . "\n\n"; $info .= "Remote Host: " . $remote_host . "\n\n"; $info .= "Remote Port: " . $remote_port . "\n\n"; $info .= "Request URL: " . $request_url . "\n\n"; $info .= "Agent: " . $agent . "\n\n"; $info .= "-----------------------------------------"; fwrite($file, $info); } ?> <center>*Are You Looking to Go Ahead and Get My Email Guide? </center> <br /> <br /> <br /> <center> <ul> <li>Make Thousands Monthly</li> <li>Do All Kinds of Things You Couldn't Before</li> <li>Get Whatever Car You Want!</li> <li>If you said yes then click the link below!</li> </ul> </center> <center> <a href="http://www.tracklead.net/click.track?CID=107578&AFID=112392&ADID=241750&SID=fb"> Rags to Riches Story Here! </a> </center> </body> </html> Link to comment https://forums.phpfreaks.com/topic/203801-why-would-_serverrequest_uri-come-up-empty-or-null/#findComment-1067406 Share on other sites More sharing options...
mrMarcus Posted June 3, 2010 Share Posted June 3, 2010 $_SERVER['REQUEST_URI'] is the only value not showing up? And when you say NULL, is it printing NULL in the file or do you just mean no value is present? Link to comment https://forums.phpfreaks.com/topic/203801-why-would-_serverrequest_uri-come-up-empty-or-null/#findComment-1067410 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.