why my code wont redirect the page

mzk777

Honorable
Mar 25, 2015
26
0
10,530
im coding a simple php forum but when i logout / register / log in it doesnt redirect me back to the main menu and shows blank page instead heres example of my script
<?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');
}
?>
 

mzk777

Honorable
Mar 25, 2015
26
0
10,530


my bad forgot to tell that i defined it in a script and included it heres the defining script
<?php
function redirect($page = FALSE, $message = NULL, $message_type = NULL) {
if (is_string ($page)) {
$location = $page;
} else {
$location = $_SERVER ['SCRIPT_NAME'];
}

//Check For Message
if($message != NULL){
//Set Message
$_SESSION['message'] = $message;
}
//Check For Type
if($message_type != NULL){
//Set Message Type
$_SESSION['message_type'] = $message_type;
}

header ('Location: '.$location);
exit;
}
 

mzk777

Honorable
Mar 25, 2015
26
0
10,530


yeah i just made sure
heres the domain test login / register / logout
http://www.dev2.nilemarketing.com/talkingspace
everything fine but not redirecting
the generated code is empty html body