How to use $_SERVER['HTTP_REFERER'] correctly in php?
问题 Lets say i have two pages page1.php and page2.php and i want page2.php to be displayed only if it is redirected form page1.php and i inserted this code to page2.php if($_SERVER['HTTP_REFERER'] == "page1.php") { //keep displaying page2.php }else{ //if it is not redirected from page1.php header('Location:page1.php') //redirect the user back to page1.php } this code worked fine until i have a form and a submit button on page2.php when the submit button is clicked the page refreshes which means