It depends on the database type you're using. You use different connection measures, but basically the same idea:
-- Connect to database
-- Grab info from row that user is on
-- Compare db info and input info
-- Redirect accordingly
Now, here's how it's done with mySQL:
<?php
$uname = isset($_POST['uname'])?($_POST['uname']): "";
$pass = isset($_POST['pass'])?($_POST['pass']): "";
if (isset($_POST['checklog']) == true)
{
$conn = mysql_connect('localhost', 'DBusername', 'DBpassword');
mysql_select_db('database_name', $conn);
$query = "SELECT * FROM `table_name` WHERE username = $uname LIMIT 1";
$result = @mysql_query($query);
if(!$result)
{
print "<I> Username Error!! </I>";
}
else {
$row = mysql_fetch_array($result);
if($pass != $row['password']) {
print "<I> Username Error!! </I>";
}
else {
session_start();
$_SESSION['_suname'] = $uname;
$_SESSION['_spass'] = $pass;
header("Location: mainmenu.php?" .SID);
}
}
}
?>
<HTML><HEAD><TITLE> Temp Logon page </TITLE></HEAD>
<BODY>
<H2> Logon Here: </H2><BR>
<FORM name='templogon' method='POST' action='templogon.php'>
Username: <INPUT type='text' name='uname'><BR>
Password: <INPUT type='password' name='pass'><BR>
<INPUT TYPE='submit' name='checklog' value='submit'>
</FORM></BODY></HTML>
You will have to fill in your own values in certain places, like the connection settings, and the query, but that's a starting point.
~Brett