php - check if user didnt come from url -


how check in php if user didn't come url , redirect them?

for example, if came hello.php, nothing happen, if came other page, redirected?

you can use $_server['http_referer'] value determine user came from:

$referer = $_server['http_referer']; if (preg_match('/hello\.php$/', $referer) === 1) {     echo 'came hello.php'; } else {     echo 'did not come hello.php'; } 

you should careful, however. http_referer header value can changed client. in other words, never assume correct.


Comments