Web Hosting Talk







View Full Version : PHP referer


raulgonzalez
11-01-2004, 06:51 PM
Hello I have this script that detects the referer url and it gives a response accordingly

<?

IF

($_SERVER["HTTP_REFERER"] == "http://somesite.com/file1.html")

{

echo "response_1";

}

else

{

echo "response_2";

}

?>

The problem is that when the "http://somesite.com/file_1.html" website redirects someone from another file, but from the same website. Example "http://somesite.com/file_2.html", it gets the "response_2". How can I come about and tell the script to vaidate all incoming data from the same website. This is not intended for secure purpose by the way. Thanks.

azizny
11-01-2004, 07:41 PM
use this

if( ereg("somesite.com",$_SERVER['HTTP_REFERER"])){

raulgonzalez
11-02-2004, 02:35 PM
Thanks it worked.

I just had to fix it, you had the beginning of it in single quote and the end in double quote.

$_SERVER['HTTP_REFERER"]

Thanks.