how to redirect/dispatch in php?
This question already has an answer here:
Use header function like this:
header('Location: login.php');
exit;
But don't print any html output before calling header function else it will result in an error.
Try something like this :
<?php
session_start();
//do some login processing
if(login === true){
exit(header('Location: home.php'));
}else{
//Extra marks set a reason why failed
$_SESSION['error'] = 'Some error about why it failed';
exit(header('Location: login.php'));
}
?>
exit(header('Location: *'));
is what your after.
header('Location: http://someweb.com');
will redirect the user.
上一篇: 如何刷新表单提交的PHP页面?
下一篇: 如何重定向/调度在PHP?