Today, I learned about the URL Redirection in PHP.
- Manual redirect
- The simpest technique is to ask the visitor to follow a link to the new page, usually using an HTML anchor like:
Please follow <a href="https://www.example.com/">this link</a>
- Using server-side scripting for redirection
- One can use the "header" function:
header("HTTP/1.1 301 Moved Permanetly");
header("Location: https://www.example.com/");
exit();
Header()
Example:
<?php
session_start();
if (isset($_POST['type'])) {
header("Location: user.php");
return;
}
else if ($_POST['type'] == 'manager'){
header("Location: manage.php");
return;
}
else {
header ("Location: http://www.~.edu");
return;
}
}
?>
'Web Programming ๐ > Back-End ๐ฅท๐ป' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Session with PHP (0) | 2023.05.07 |
---|---|
Cookies (0) | 2023.05.03 |
PHP Exercise: GuessGame (0) | 2023.04.25 |
PHP Exercise: popcorn bill (0) | 2023.04.25 |
PHP Form (0) | 2023.04.25 |