I’ve looked at several of the “PHP redirect not working ……” posts, but I haven’t had any luck figuring out what is going on with my problem.
The code below always goes to teacherActivity_2.php
even though the 2nd if passes and should redirect to teacherActivity_3_shadowT.php
. If I comment out the teacherActivity_2.php
, the page redirects (as expected) to teacherActivity_3_shadowT.php
. I think I’m missing some obscure rule that I should know but don’t. Any ideas?
Why does this redirect to teacherActivity_2.php
instead of teacherActivity_3_shadowT.php
?
JavaScript
x
if($test == 'yes') {
if($_SESSION['wblReporting']['activity'] == 'shadowT'){
header('Location: /app/do_cte-wbl/forms/teacherActivity_3_shadowT.php');
}
header('Location: /app/do_cte-wbl/forms/teacherActivity_2.php');
}
?>
Advertisement
Answer
Try the following:
JavaScript
if($test == 'yes') {
if($_SESSION['wblReporting']['activity'] == 'shadowT'){
header('Location: /app/do_cte-wbl/forms/teacherActivity_3_shadowT.php');
die();
} else {
header('Location: /app/do_cte-wbl/forms/teacherActivity_2.php');
die();
}
}
This worked no matter how many elseifs I used.