I have made a form that whenever the user completes the registration successfully, it redirects him/her to a new page (thankyou.php) saying "thank you for registering, bla bla....". It works fine but I want to prevent the direct access to thankyou.php so if the user types "www.mysite.com/thabkyou.php/" it redirects him to the form without displaying the thank you message. But in case the user succeeds to register, thankyou.php opens & displays the thank you message. Do you have any idea how can I do that ?
Set a cookie or a session variable on the form page. Check for the value on the thankyou page. //Form.php session_start(); $_SESSION['some_variable'] = true; //Thankyou.php If (!$_SESSION['some_variable']){ header("Location: goback.php")};
SOLVED..! Thank you very much. I had to add session_start(); at the beginning of thankyou.php. Very helpful.