Having problems with IF STATEMENT PLEASE HELP

When a user types in the correct username and password it should say “your in”.

and when a user types in a correct username and wrong password it should say "incorrect

password". However, even if a user types in a correct username and password it says

“incorrect password” instead of “your in”. I have been trying to solve this for 4 hours I

just don’t know what the problem is. Please help me, it is very frustrating.

[php]<?php

	 $username = $_POST['username'];
	 $password = $_POST['password'];

if($username&&$password)

{
$connect = mysql_connect (“Localhost”,“lesultra”,“soulplane”) or die(“couldn’t connect”);
mysql_select_db(“lesultra_members”) or die(“couldn’t find db”);

$query = mysql_query (“SELECT * FROM advertisers WHERE username=’$username’”);

$numrows = mysql_num_rows($query);

if ($numrows!=0)
{

while ($row = mysql_fetch_assoc($query))

{

 $dbusername = $row ['username'];
 $dbpassword = $row ['password'];
 }

if($username==$dbusername&&$password==$dbpassword)

{
echo “YOUR IN!”;
}

 else
     echo "Incorrect password!"; 

}

else
die(“That user doesn’t exist”);

}

else
die(“Please enter a valid username and password!”);

?>

      [/php]

Before this if statement:
[php]if($username==$dbusername&&$password==$dbpassword)[/php]

Put this to check what values you are dealing with (just a quick, simple debug):
[php]echo ‘

’;
print_r(array(
“username” => ‘[’.$username.’]’
,“dbusername” => ‘[’.$dbusername.’]’
,“password” => ‘[’.$password.’]’
,“dbpassword” => ‘[’.$dbpassword.’]’)
);
echo ‘
’;[/php]

That should help you verify what your database is returning in comparison to what the posted values actually are.

Sponsor our Newsletter | Privacy Policy | Terms of Service