when the user login with the username and password via a form
<input name="username" type="text">
<input name="password" type="text">
All you have to do is to do post it to a form that process it.
example.php
<?
$username = $POST['username'];
$password = $POST['password'];
//check whether username and password matches/exists
$query = mysql_query("select * from databasename where username='$username' and password = password('$password')");
if (!query) {
echo "Unable to perform query";
} elseif (mysql_num_rows($query) <= 0) {
echo "Your username and password do not match or exists.";
} else {
LOGIN();
}
Its recommended that you only report the error as "Username do not exist or your password do not match" instead of specifying "Your username do not exist." and "Password incorrect" due to security issues.