A simple one would look something like this..
//build the query to check for both values
$sql ="select * from table where user_name = '$user_name' and user_password = '$user_password'";
// connect to the DB server and select a DB
mysql_connect ("my.host.com","mysql_username","mysql_password");
mysql_select_db ("my_database");
// execute the query
$result=mysql_query($sql);
// check result resource
if ($result) {
echo "valid";
} else {
echo "not valid";
}
This is a simple example, you would need to encrypt the password before passing it to the query, and do validation on the data in general.