How can the header() function be used in PHP to redirect to a specific URL after form submission?
To redirect to a specific URL after form submission in PHP, you can use the header() function with the Location parameter set to the desired URL. This function sends a raw HTTP header to the browser, which will redirect the user to the specified URL.
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Process form data here
// Redirect to a specific URL after form submission
header("Location: http://www.example.com/thankyou.php");
exit();
}
?>
Keywords
Related Questions
- How can the Keysize be increased to the required value of 16, 24, or 32 in mcrypt_encrypt?
- What are some recommended web hosting services for storing PHP files for online access to SQL database values?
- What potential issue could arise if the query in the PHP code does not return any matching records?