What role does the header() function play in PHP and how can it be utilized for page redirection within a script?
The header() function in PHP is used to send a raw HTTP header to the client. It is commonly used for page redirection within a script by sending a "Location" header with the desired URL. This can be useful for redirecting users after form submissions, authentication, or any other scenario where a page needs to be redirected programmatically.
<?php
// Redirect to a new page after 3 seconds
header("Refresh: 3; url=destination_page.php");
exit;
?>
Related questions
-
SQL injection form validation XSS attacks
-
PHP form submission email sending
-
PHP includes website management code organization