check use pass on database

HI

guys can some one help me about php code that:

checked database (mysql) if the requested username & password exist return value “true” and if not exist return “false” ?!!

the requested username and password will send form local pc to “an example auth.php” page (and this cod must be in auth.php).

You mean a user gives a username and a password and you need to check in the database if this user is known to the system?

[php]
$username = $_REQUEST[‘username’];
$password = $_REQUEST[‘password’];

$table = ‘users’; // or any name you use for the registered user table
$query = “SELECT * FROM $table WHERE username = ‘$username’ AND password = ‘$password’”;

$result = mysql_query( $query );
if ( mysql_error() )
{ echo "An error has occurred executing query [$query] : ". mysql_error();
}
$login = mysql_fetch_assoc( $result );
if ( $login )
{ // Here you have a succesful match, the user/password combination exists
} else
{ // Here either the username or the password or both are wrong, no match found
}
[/php]

Does this help?

Good luck,
O.

Sponsor our Newsletter | Privacy Policy | Terms of Service