How does header('Location: ...') work in PHP and what is its purpose?
The header('Location: ...') function in PHP is used to redirect a user to a different page. This is commonly used after processing a form submission or when a user needs to be redirected to a different page based on certain conditions. It sends an HTTP header to the browser with the new location, causing the browser to load the new page.
<?php
// Redirect to a different page
header('Location: https://www.example.com/new_page.php');
exit;
?>