im working on a simple php forum when i log in / out or register it wont redirect me back to the index.php my log out code for example
<?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');
}
and my redirect definition code
<?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();
}
the defining script is in a php file which included before the logout script