How can a PHP form process and redirect to a specific URL after submission?
To process a PHP form and redirect to a specific URL after submission, you can use the header() function to send a raw HTTP header to the browser. After processing the form data, you can use header('Location: specific_url.php') to redirect the user to the desired URL.
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Process form data here
// Redirect to specific URL
header('Location: specific_url.php');
exit;
}
?>
Related Questions
- What are the limitations of forcing browser caching through PHP headers and how can users bypass this caching?
- How can the PHP error log be utilized effectively to debug issues related to the installation and usage of the Imagick extension?
- What are some best practices for beginners to follow when learning PHP?