Rifts Posted October 20, 2010 Share Posted October 20, 2010 I'm trying to make the simplest login and this isnt working can someone explain why? thanks if ($_POST['user'] == 'admin' && $_POST['pass'] != '1234') { echo "fail"; } else { echo "win"; no matter what I do it says win Link to comment https://forums.phpfreaks.com/topic/216383-simplest-login-ever-wont-work/ Share on other sites More sharing options...
The Little Guy Posted October 20, 2010 Share Posted October 20, 2010 Have you tried echoing out $_POST['user'] and $_POST['pass']? Link to comment https://forums.phpfreaks.com/topic/216383-simplest-login-ever-wont-work/#findComment-1124431 Share on other sites More sharing options...
Rifts Posted October 20, 2010 Author Share Posted October 20, 2010 yeah and they are 100% correct Link to comment https://forums.phpfreaks.com/topic/216383-simplest-login-ever-wont-work/#findComment-1124434 Share on other sites More sharing options...
PaulRyan Posted October 20, 2010 Share Posted October 20, 2010 This is most likely one of the following reasons: 1 - The pass vaildation is using Not Equal To(!=) instead of Equal To (==) 2 - The form input fields are not named correctly. Change the names to match. If you are still stuck post your whole code, so we can have a look over it. Regards, Paul. Link to comment https://forums.phpfreaks.com/topic/216383-simplest-login-ever-wont-work/#findComment-1124435 Share on other sites More sharing options...
samtwilliams Posted October 20, 2010 Share Posted October 20, 2010 Try this; <?PHP if ($_POST['user'] == 'admin' && $_POST['pass'] == '1234') { echo "fail"; } else { echo "win"; }?> Link to comment https://forums.phpfreaks.com/topic/216383-simplest-login-ever-wont-work/#findComment-1124438 Share on other sites More sharing options...
Rifts Posted October 20, 2010 Author Share Posted October 20, 2010 yeah i actaully just changed it to this and it workes now if ($_POST['login'] == 'admin' && $_POST['pass'] == '1234') { echo "win"; } else { echo "fail"; } Link to comment https://forums.phpfreaks.com/topic/216383-simplest-login-ever-wont-work/#findComment-1124443 Share on other sites More sharing options...
j.smith1981 Posted October 20, 2010 Share Posted October 20, 2010 I always have the same trouble, just fiddling around with it usually helps myself. Its like I always use if(!isset($_SESSION)) is the one I start off with and then just bump it up later on, adding an stage of it every time to see where I am going wrong usually helps me, but thats just my way of doing things. Link to comment https://forums.phpfreaks.com/topic/216383-simplest-login-ever-wont-work/#findComment-1124446 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.