I’m trying to find if variables (using GET) exist using an if statement, but I can’t get them to work on my web server, but my local server works fine.
I have if statements like these in my PHP:
if(isset($_GET['typeQ']) && $_GET['typeQ'] == 4 && isset($_GET['searchQ'])){
header("Location: schoolEdit.php?schoolid=".$_GET['searchQ']."");
} else if(isset($_GET['typeQ']) && $_GET['typeQ'] == 5 && isset($_GET['searchQ'])){
header("Location: vehicleEdit.php?vehicleid=".$_GET['searchQ']."");
} else if(isset($_GET['typeQ']) && $_GET['typeQ'] == 6 && isset($_GET['searchQ'])){
header("Location: driverEdit.php?driverid=".$_GET['searchQ']."");
} else if(isset($_GET['typeQ']) && $_GET['typeQ'] == 3 && isset($_GET['searchQ'])){
header("Location: studentEdit.php?studentid=".$_GET['searchQ']."");
}
When I go to this URL on my localserver (http://localhost/voyageur/index2.php?searchQ=1&typeQ=6), it sees that “typeQ” is set as 6 and “searchQ” is set to something and runs the header code. But on my web server, it doesn’t run any of these using the same type of URL, it just skips them as if none of them were set.
Is there something I need to configure on my web server to get this to work properly like I have it working locally?
Should have thought of this, but I got this to work by moving the if statements up higher in the code. Still strange how I didn’t get “headers already sent” errors or something.
Thanks for the help everyone 🙂