ostig Posted December 4, 2008 Share Posted December 4, 2008 I have an authentication script that checks for the validity of userid/password entered on a form by comparing to a table in MySQL. The script works fine in IE and Safari, but does not work in FireFox. There are two conditional IF statements that are apparently not being processed when the user is in the FireFox browser, allowing them to enter in invalid data (or no data) and gain access because the script falls through to the "success" part of the code. The IF statements: //User Not Found if(!$result || (mysql_numrows($result) < 1)){ echo "<meta http-equiv='refresh' content='0;url=baduser.php?From=$olive&User=$user1'>" ; $baduser = "1"; } //See if the password for the user is correct if ($baduser == "0") { $query = "SELECT * FROM subscribers WHERE username='$user1' AND userpass='$pass1'"; $result = mysql_query($query) or die ("could not execute query"); if(!$result || (mysql_numrows($result) < 1)){ echo "<meta http-equiv='refresh' content='0;url=badpass.php?From=$olive&User=$user1'>" ; } } I am new to PHP , I am assuming there is a way around this but - no clue. Any pointers appreciated. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/135544-solved-conditional-if-statements-not-working-in-firefox/ Share on other sites More sharing options...
gevans Posted December 4, 2008 Share Posted December 4, 2008 The problem will be with your html not php, php is server side and will not be affected by different browsers Quote Link to comment https://forums.phpfreaks.com/topic/135544-solved-conditional-if-statements-not-working-in-firefox/#findComment-706105 Share on other sites More sharing options...
Mchl Posted December 4, 2008 Share Posted December 4, 2008 This code is not browser dependent. Is this the whole script? Instead of echoing <meta refresh tags for redirection use header("Location: badpass.php?From=$olive&User=$user1"); Quote Link to comment https://forums.phpfreaks.com/topic/135544-solved-conditional-if-statements-not-working-in-firefox/#findComment-706108 Share on other sites More sharing options...
gevans Posted December 4, 2008 Share Posted December 4, 2008 if you want it all done in php try it like this; //User Not Found if(!$result || (mysql_numrows($result) < 1)){ header('Location: baduser.php'); exit(); } //See if the password for the user is correct if ($baduser == "0") { $query = "SELECT * FROM subscribers WHERE username='$user1' AND userpass='$pass1'"; $result = mysql_query($query) or die ("could not execute query"); if(!$result || (mysql_numrows($result) < 1)){ header('Location: baduser.php'); exit(); } } Quote Link to comment https://forums.phpfreaks.com/topic/135544-solved-conditional-if-statements-not-working-in-firefox/#findComment-706109 Share on other sites More sharing options...
gevans Posted December 4, 2008 Share Posted December 4, 2008 EDIT: Mchl beat me to it Quote Link to comment https://forums.phpfreaks.com/topic/135544-solved-conditional-if-statements-not-working-in-firefox/#findComment-706110 Share on other sites More sharing options...
ostig Posted December 4, 2008 Author Share Posted December 4, 2008 Unbelievable, the speed and the accuracy of the responses here on PHPFreaks. Thank you BOTH so much for the help, the script is working now. Plus I have a new command to learn about, "header". Cheers! Quote Link to comment https://forums.phpfreaks.com/topic/135544-solved-conditional-if-statements-not-working-in-firefox/#findComment-706128 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.