if($row['usr'])
{
// If everything is OK login
$_SESSION['usr']=$row['usr'];
$_SESSION['id'] = $row['id'];
$id = $_GET['id'];
$_SESSION['rememberMe'] = $_POST['rememberMe'];
// Store some data in the session
setcookie('tzRemember',$_POST['rememberMe']);
}
else $err[]='Wrong username and/or password!';
}
if($err)
$_SESSION['msg']['login-err'] = implode('<br />',$err);
// Save the error messages in the session
$goHere = 'Location: /index2.php?id=' . $id;
header($goHere);
exit;
}
This currently gives an output in the url like index2.php?id= NOT index2.php?id=105 or any integer really.
Anyone see why this UPDATED code isnt working?
You’re setting the value of
$idonly if$row['usr']is truthy. Move the$id = $_GET['id'];line outside the conditional.Also, if you use a similar url to reach this page (
index1.php?123) then$_GET['id']will not be set. You need to name the parameter (index1.php?id=123).