At 10/26/2006 11:16 AM, afan@xxxxxxxx wrote:
Would it be ok to use the same code to check if customer is loged in?
$query = mysql_query("
SELECT COUNT(Username) as NoOfRecords
FROM customers
WHERE Username = '$Username' AND Password = '$Password'");
if (mysql_result($query, 0) == 0)
I'd question whether you really needed to get a record count. If
your logon system is robust, each member will be listed only once;
even if not, it's probably not the number of records you're
interested in learning but whether or not there are any. I'd suffice with:
SELECT Username
FROM customers
WHERE Username = '$Username' AND Password = '$Password'
LIMIT 1,0;
In a case like this, where I'm confident I have either one record or
none, I'd be happy to use mysqsl_num_rows().
In the example above, which field you select is arbitrary, unless you
actually want more information about the logged-on user:
SELECT FirstName, LastName, SecurityLevel
FROM customers
WHERE Username = '$Username' AND Password = '$Password'
LIMIT 1,0;
Regards,
Paul
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php