Hi, I'm having a problem with some php that I've written to check to see if the site calling my PHP script is in fact from my site, and if they're not I have it read a document to tell them that they can't call the script from outside of my site. The below section of the script works absolutely fine, but the problem is that getenv(HTTP_REFERER) doesn't return anything. From what I'm guessing this is because I am calling the php script from a javascript function (semi ajax using xmlhttprequest). I don't understand why getenv(HTTP_REFERER) doesn't return a value though because it's still being called from within my site... Can anyone help me?
P.S. The fact that getenv(HTTP_REFERER) doesn't return a value makes it so that no matter what every time my script is called I get the "outside.html" file.
PHP Code:
$homeurl = "www.somewebsite.com";
$callinghttp = getenv("HTTP_REFERER");
$callingurl = ereg_replace("http://", "", $callinghttp);
$url = stristr($callinghttp, $homeurl);
if ($url === false) {
readfile("outside.html");
exit;
}
P.P.S. My page that calls my javascript function is html, and the function is called from a form onSubmit.