Backendly redirecting a user from a contact form webpage to a success webpage
+1
−0
On a CentOS Apache-MySQL-PHP environment I have a website with a simple HTML-PHP-CSS contact form; the contact form itself is working.
This is how I backendly redirect a user from the contact form webpage to a success message webpage after a successful submission, based on the built-in W3C-developed-behavior of the form's HTML structures:
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
header('Location: URL_COMES_HERE');
exit;
}
Would you suggest to improve this code somehow? Maybe I lacked some validations.
1 comment
No time for a full answer, so just a comment: I do the same sort of thing, but in the first program, that is, inside the if() statement, I add: validation of input, preprocessing of the data (if appropriate) - that way, if the form is bad (e.g., client-side validation insufficient and/or bypassed), the original form can be redisplayed easily rather than bouncing to the destination and then back. — manassehkatz 2 days ago