Reputation: 37
I am using following code to redirect
header('Location: '.$fileID.'php');
}
else if (!isset($_SESSION['login']))
echo '<p>you need to register first.</p>' ;
?>
$fileID has a value bacuse I am using this value in other part of code and that works fine. I also tried
echo '<script>window.location="'.$fileID.'php"</script>';
but got a notfound error. I would like to get it working by any of these methods but would prefer the header method. Any help is appreciated.
Upvotes: 0
Views: 88
Reputation: 561
I wanted to put this in a comment but I don't have enough reputation :( Anyways try changing your header from this:
header('Location: '.$fileID.'php');
To this:
header('Location: '.$fileID.'.php');
Upvotes: 1
Reputation: 32340
You should exit;
after redirect with headers, because the script will go on executing otherwise which can lead to unintended side effects.
but got a notfound error.
URL seems wrong, echo the output and see if it matches your expected location.
Upvotes: 1