Question

I have a web page and I need to accept some of visitors if it is just from a spesific page.

For Example: If visitor goes example.com/member to example.com/specific it will ok. But if user goes any other place or just from address bar of browser, It will say "connection failed"

How can I do this with php? Thanks.

Was it helpful?

Solution

This isn't fool proof though, so don't use it for any authentication or security purpose

<?php
if(strtolower($_SERVER['HTTP_REFERER'])=="http://yourallowedurl.com/etc.html")
{
    echo "OK";
}
else
{
    echo "connection failed";
}
?>

Review This

And This

Note: You might want to create a session for the people who are logged in and allow only those with proper session values set to visit that protected page.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top