简体   繁体   中英

How can accept connection from specific page?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM