I have echoed out the header and the syntax appears correct but the redirect does not work.
The page determines the code from the URL.
The if statement is working correctly to determine which page is required, but the header is not redirecting the user to the URL specified.
Can anyone see what I have done wrong?
<!DOCTYPE html>
<html>
<head>
<title>Finding your code ... </title>
</head>
<body>
<?php
// directs the user to page based on code
$code = $_GET['c'] ;
$code = (int) $code;
$page1 = 'https://example.com/dogs';
$page2 = 'https://example.com/cats';
$page3 = 'https://example.com/frogs';
$page4 = 'https://example.com/cows';
$page5 = 'https://example.com/else';
if ( $code >= 1 && $code <= 10 || $code >= 100 && $code <= 150 ){
// Do something when num is between 1 and, or 100 and 150
//echo $page1 ;
$url = $page1 ;
header("Location: $url") ;
die() ;
}
if($code >= 11 && $code <= 20) {
$url = $page2 ;
echo $url ;
header("Location: $url") ;
die() ;
}
if($code >= 21 && $code <= 30) {
$url = $page3 ;
header("Location: $url") ;
die() ;
}
if($code >= 31 && $code <= 40) {
$url = $page4 ;
header("Location: $url") ;
die() ;
}
else {
$url = $page5 ;
header("Location: $url") ;
die() ;
}
?>
</body>
</html>
Thanks