Hello again,

I'm trying to write a script that has a member's area in it. So far I've
been able to successfully validate only one username and only one
password but now I'm going big and trying to compare it with a table in
my MySQL database. Everything goes nice and smooth until I actually try
and enter in my username and password. I type it in, copy and paste,
whaetever and it tells me the error I wanted it to say "The username and
password is not a good combo." I've copied and pasted the username and
password from the database directly yet it still gives me this error.
Here's my code for the login() function that logs the user in:

function login($username, $password)
  $conn = $main;
  if (!$conn)
    return 0;

  $result = mysql_query("select * from user 
                         where username='$username'
                         and passwd = '$password'");
  if (!$result)
     return 0;
  if (mysql_num_rows($result)>0)
     return 1;
     return 0;

Here's the code for the part that calls the login() function:

if(login($user, $pass))
        $valid_user = $user;
        echo "<font face='Arial, Helvetica, sans-serif'
size='3'><center><b>You supplied an invalid username and password combo.
Try again please.</b></center>";

And here's the part that connects to the database:

# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_main = "localhost";
$database_main = "mom";
$username_main = "root";
$password_main = "";
$main = mysql_pconnect($hostname_main, $username_main, $password_main)
or die(mysql_error());

Does anyone see why it's doing this to me? Please help!!


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to