Jump to content

[SOLVED] conditional if statements not working in FireFox


ostig

Recommended Posts

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.

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();
    }
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.