I have a redirect PHP page which checks a URL Parameter and redirects to one of two pages depending on if the variable 'shore' is either 1 or not. My problem however, is that no matter what I do, the page is redirecting to the first option. Can anyone see anything obvious that I am missing?
Many thanks
<?php
require_once('Connections/ships.php');
if ($_GET['shore'] = "1") {
header( 'Location: shore_establishment.php?ship_id=' .urlencode($_GET['ship_id']) . "?shore=1");
//echo"first";
} else if ($_GET['shore'] = "0") {
header( 'Location: shipinfo.php?ship_id=' .urlencode($_GET['ship_id']). "?shore=0");
//echo"second";
};
?>
Like, @CommuSoft said, and your second ?
in your $_GET
request should be an &
instead.
You should use ==
instead of =
to check the content of a variable
Furthermore I would advise you to use else
instead of else if
since there are only two options (this is more robust and in case in the end a third variable is introduced, the page would still do something).