How can a PHP script use the header() function to redirect back to a specific page, like login.php?
To redirect a PHP script back to a specific page like login.php, you can use the header() function with the Location parameter set to the desired page's URL. This will send a raw HTTP header to the browser, instructing it to redirect to the specified page. Make sure to call this function before any output is sent to the browser to avoid any errors.
<?php
// Redirect to login.php
header("Location: login.php");
exit;
?>
Related questions
-
PHP debugging error message
-
PHP forum categorization skill level
-
PHP image gallery dynamic