Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/119131-php-header/
Share on other sites

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 ;)

Link to comment
https://forums.phpfreaks.com/topic/119131-php-header/#findComment-613409
Share on other sites

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.

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/119131-php-header/#findComment-613411
Share on other sites

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)

Link to comment
https://forums.phpfreaks.com/topic/119131-php-header/#findComment-613417
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.