whelpton Posted February 26, 2011 Share Posted February 26, 2011 Can anyone explain to me why this system isnt working? I have no clue why it shouldnt be. The pin number is passed from a form to this script, which then determines if a users pin is correct and if so, forwards them onto the relevant page. Otherwise, it returns them to the login. <?php session_start(); $pin=$_POST['pin']; if ($pin='7221') { $_SESSION['pin']='7221'; $_SESSION['name']='Keith D Whelpton'; header('Location: phonesystem.php'); } elseif ($pin='3585') { $_SESSION['pin']='3585'; $_SESSION['name']='Luke S Barnes'; header('Location: phonesystem.php'); } else { header('Location: phonelogin.php'); } ?> Link to comment https://forums.phpfreaks.com/topic/228942-passing-a-pin-to-a-form/ Share on other sites More sharing options...
whelpton Posted February 26, 2011 Author Share Posted February 26, 2011 if the form is used, it automatically sets the session as 7221 instead of the other option & the elseif command doesn't redirect unrecognised users away. Link to comment https://forums.phpfreaks.com/topic/228942-passing-a-pin-to-a-form/#findComment-1180071 Share on other sites More sharing options...
Altrozero Posted February 26, 2011 Share Posted February 26, 2011 In your if statement you need to use a double == sign e.g if($pin == "1111") { } else if ($pin == "2222") { } Link to comment https://forums.phpfreaks.com/topic/228942-passing-a-pin-to-a-form/#findComment-1180072 Share on other sites More sharing options...
whelpton Posted February 26, 2011 Author Share Posted February 26, 2011 Excellent. Thank you very much for your help altrozero Link to comment https://forums.phpfreaks.com/topic/228942-passing-a-pin-to-a-form/#findComment-1180075 Share on other sites More sharing options...
Altrozero Posted February 26, 2011 Share Posted February 26, 2011 You're welcome Link to comment https://forums.phpfreaks.com/topic/228942-passing-a-pin-to-a-form/#findComment-1180077 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.