I’m making a site and part of it is additional information after you have signed up. After you have filled out the boxes and all in register.php you’re sent to signup.inc.php (Through the post method) and in there, there’s some code that checks if you have been sent by the post method in register.php.
<?php if (isset($_POST["signup-submit"])){ /* Code for sign up*/ } else { header("Location: ../register/register.php"); exit (); } ?>
I want to do the same thing again but registered.php checking if the person was sent by signup.inc.php to registered.php with some php inside the registered folder. I can’t use the method I used before though as there’s no post method in signup.inc.php. I use the
/*after all script was successfully run and the information was sent to the database*/ ("Location: ../register/registered.php"); exit ();
method instead. Is there any code I can use to do as I want?
register.php>signup.inc.php>registered.php
Advertisement
Answer
<?php if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER']!='') { /* Code for sign up*/ } else { header("Location: ../register/register.php"); exit (); } ?>
You can use the above code, if REFERER is not empty you can write your logic for signup. otherwise it will redirect to register.php