<?php
if(isset($_POST['do_logout'])){
//Create User Object
$user = new User;
if($user->logout()){
redirect('index.php','You are now logged out','success');
}
} else {
redirect('index.php');
}
和我的重定向代码
<?php
function redirect($page = FALSE, $message = NULL, $message_type = NULL) {
if (is_string ($page)) {
$location = $page;
} else {
$location = $_SERVER ['index.php'];
}
if($message != NULL){
$_SESSION['message'] = $message;
}
if($message_type != NULL){
$_SESSION['message_type'] = $message_type;
}
header('Location: '.$location);
exit();
}
定义脚本位于注销脚本
之前的php文件中答案 0 :(得分:0)
<?php
function redirect($page = FALSE, $message = NULL, $message_type = NULL) {
$location = (is_string($page)) ? $page : 'index.php';
if($message != NULL){
$_SESSION['message'] = $message;
}
if($message_type != NULL){
$_SESSION['message_type'] = $message_type;
}
header('Location: '. $location); exit();
}