User Authentication

From: Date: Fri, 27 Feb 2004 14:26:45 +0000
Subject: User Authentication
Groups: php.db 
Request: Send a blank email to php-db+get-33183@lists.php.net to get a copy of this message
Hello, I could use some help here. I have a script that checks a user name and password against the MySQL DB. I have it set as a function so I included/require it on the page. Here is the script: function login($username, $password) // check username and password with db { // connect to db $conn = db_connect(); if (!$conn)
    return false;
// check if username $result = ("select user_id password FROM users WHERE username='$username' AND password=md5('$password')"); if (!$result)
     return false;
if (mysql_num_rows($result) > 0 )
     return true;
else
     return false;
} Here is my DB script: function db_connect() { // connect to database $result = mysql_connect("localhost", "xxxxxx", "xxxxxx"); if (!$result) return false; if (!mysql_select_db("xxxxxxxx")); return false; return $result; } When I change the "return false" to "return true" in the first script (login) it authenticates, but logs any one in. Not good. Does anyone have any ideas or suggestions? Thanks in advance, Craig __________________________________ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: choffman@eclimbmedia.com w: www.eclimbmedia.com _________________________________

« previous php.db (#33183) next »