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. 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 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"); 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(); } } 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 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! 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
Archived
This topic is now archived and is closed to further replies.