Jump to content

[SOLVED] conditional if statements not working in FireFox


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.