leony Posted August 11, 2008 Share Posted August 11, 2008 Hello, I have a page which a customer enters all his details and when he clicks on "Send this form", all the information goes to form_process.php. From this page (if validation is OK), I would like to direct the person the the confirmaton.php (which says Thank you blah...blah) However, even if someone calls this confirmation.php directly, they will see the page straight away without going through the validation. How can I prevent that? Basically what I want to do, if confirmation.php is called directly, the person needs to be directed to the home page etc... Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/119131-php-header/ Share on other sites More sharing options...
trq Posted August 11, 2008 Share Posted August 11, 2008 if (isset($_POST['submit'])) { // do confirmation } else { header("Location: index.php"); } Quote Link to comment https://forums.phpfreaks.com/topic/119131-php-header/#findComment-613408 Share on other sites More sharing options...
wildteen88 Posted August 11, 2008 Share Posted August 11, 2008 Check to see if the user accessed confirmation.php from form_process.php. or if you have sufficient form validation you shouldn't have to do this, eg // check if form is submitted if(isset($_POST['your_submit_butten'])) { // form submitted apply validation // page content here } else { // form hasn't been submit, redirect user header('Location: /index.php'); } EDIT: beaten to it Quote Link to comment https://forums.phpfreaks.com/topic/119131-php-header/#findComment-613409 Share on other sites More sharing options...
leony Posted August 11, 2008 Author Share Posted August 11, 2008 Thanks for the reply. My code structure as follows: if(isset($_POST['submit'])) { //validate //enter in the database //if everything OK; send email //if mail is successful redirect to confirmation.php } else { header("Location: index.php"); } The reason I am redirecting is to lose all submit values as the person refreshes the page again, there will be duplicate mysql rows. I do not know whether there is another way how to prevent duplicate records. Quote Link to comment https://forums.phpfreaks.com/topic/119131-php-header/#findComment-613411 Share on other sites More sharing options...
trq Posted August 11, 2008 Share Posted August 11, 2008 So whats your question/problem now? Quote Link to comment https://forums.phpfreaks.com/topic/119131-php-header/#findComment-613414 Share on other sites More sharing options...
leony Posted August 11, 2008 Author Share Posted August 11, 2008 I am not sure how to do the proper redirection to confirmation.php if I use just this: header("Location: confirmation.php"); Any pesson can see this page typing the URL. I dont want that to happen. I want to define a page source for it. (No access to confirmation.php if you are not being redirected from form_process.php) Quote Link to comment https://forums.phpfreaks.com/topic/119131-php-header/#findComment-613417 Share on other sites More sharing options...
trq Posted August 11, 2008 Share Posted August 11, 2008 Basically what I want to do, if confirmation.php is called directly, the person needs to be directed to the home page etc... The code both wildteen and myself posted needs to go in your confirmation page. Quote Link to comment https://forums.phpfreaks.com/topic/119131-php-header/#findComment-613482 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.