YEAH WORKS!
$user = ltrim(rtrim($POST['f_user']));
$pass = ltrim(rtrim($POST['f_pass']));
if(!authenticate($user, $pass)) {
echo "no user found";
} else {
//found user, continue with script!
}
function authenticate($the_user, $the_pass)
{
include('connect.php');
$the_user = addslashes($the_user);
// should be storing passwords in db in md5()
// should be doing md5() on pass
$query = "SELECT count(*)AS total FROM customers WHERE UserId = '" . $the_user . "' AND Password = '" . $the_pass . "'";
if (!$r = mysql_query($query)) {
die(mysql_error());
}
if (!$row = mysql_fetch_array($r)) {
return('0');
} else {
return($row['total']);
}
}