Ask a Question
Advertise on boostr.in
Organizational Research By
Surprising Reserch Topic
simple post redirect get code example
simple post redirect get code example ¬†using -'php'
I have found many sites that describes PRG, but no simple PHP code example.
Here's what I implemented:
The form.php has an action: validate.php.
The validate.php is never seen by the user; if validates all $_GET and, if valid writes it to database and generates the HTML of a confirmation page / if not valid, it generates the HTML of an error page explaining what is wrong.
Whichever HTML is generated get stored in a $_SESSION variable and then validate.php calls header('Location: <as appropriate>);.
The submitted.php of invalid_input.php (in case the user reads the URL) consists only of echo $_SESSION['form_html'];.
That seems to me like protection against both page reload and back button problems.
Did I goof by trying to reinvent the wheel?
Sep 30, 2015
to add a comment.
Related Hot Questions
Government Jobs Opening