I have a structural question for the Post Redirect Get pattern in PHP with a form process I am building. Basically, I have a PHP form at first where a user fills in fields.
Then upon pressing submit, the form posts to itself and server side validation happens testing if submitted like so:
if(isset($_POST['submitted'])){
// Firstname
if(!empty($_POST['firstname'])){
$firstName = filter_var(trim($_POST['firstname']), FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
} else {
$errors[] = "Please enter your first name";
}
}
If all of these tests pass for the form, I then do the PRG Pattern and redirect to an intermediary form like so:
if(empty($errors)){//proceed to process
//Dump your POST variables
$_SESSION['POST'] = $_POST;
// Redirect to Verification page
header('Location: quote_verify.php', true, 303);
}
So far so good. The problem lies in the intermediary form. Every PRG pattern example I have seen just basically does the redirect to the "success" page which is simple. What I wish to do is after the user submits the form and there are no errrors... then the page changes and all the data the user entered is displayed back out and a couple of buttons are presented, "EDIT", and "SUBMIT QUOTE" So basically I need an intermediary page that shows what the user entered into the primary form and then if they want to edit the form by pressing the button, it will reload the original form and RETAIN the information in the form fields so it doesn't need to be entered again....if they press SUBMIT QUOTE, it basically generates then uses PHP SwiftMailer to construct and email object and emails the form and constructs a thank you email.
It is puzzling how to construct this in either a one page PRG pattern PHP form or the 3 page pattern I have so far. Thanks Overflow!