RE: [PHP-DB] User validation problem (newbie issue)
| From: | Charles Harvey | Date: | Sat, 02 Sep 2000 19:20:58 +0000 |
| Subject: | RE: [PHP-DB] User validation problem (newbie issue) | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-2587@lists.php.net to get a copy of this message | ||
That did it! Thanks for the new way of looking at it.
Charles Harvey
Three Moons Network
http://threemoonsnetwork.net
419-818-5260
-----Original Message-----
From: php-db-return-2586-soops=threemoonsnetwork.net@lists.php.net
[mailto:php-db-return-2586-soops=threemoonsnetwork.net@lists.php.net]On
Behalf Of o.cook@etoncollege.org.uk
Sent: Saturday, September 02, 2000 11:30 AM
To: soops@threemoonsnetwork.net
Cc: php-db@lists.php.net
Subject: RE: [PHP-DB] User validation problem (newbie issue)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Try something like this:
$query = "SELECT * FROM users WHERE username='$username' AND
pwd='$pwd'";
$result = mysql_query($sql,$conn);
$rows = mysql_num_rows($result);
if ($rows == 0) {
// If no rows are returned, then the combination isn't correct.
$access = 0; // $access is a boolean (0 - denied; 1 - granted)
} elseif ($rows == 1) {
// If one row is returned, then the combination is correct.
$access = 1;
} elseif ($rows >= 1) {
// If more than one row is returned, we have issues!
echo "<p>More than one row returned. That's not good.</p>");
$access = 0;
}
Untested, but I'm sure you get the gist of it.
- -----------------------------------
Ollie Cook +44 (7946) 057 198
Programmer, XCalibre Communications
- -----------------------------------