This is a simple script, if nickname isn't set, it displays some html output that you should enter a valid nick and password...
Pretty simple, it's a stripped down version from the one I use, but it should work.
Notice that it checkes the password in md5 format (encrypted).
Search the manual for "md5" is you want to learn more about that one, don't want to use it, change the line to this...
$q = "Select count(*) from TABLE where nickname='$nickname' and password='$password'";
<?
if (!$nickname)) {
?>
<form action="<? echo $PHP_SELF; ?>" method="post">
<input type="text" name="nickname" value="nickname" size="30" maxlength="60"><br>
<input type="text" name="password" value="password" size="30" maxlength="60">
<br>
<input type="submit" name="submit" value="Klar!">
</form>
<?
}
else {
mysql_connect('SQL_HOST','SQL_USERNAME','SQL_PASSWORD') or die ("Couln't connect to the MySQL database!");
mysql_select_db('DATABASE') or die ("Couldn't connect to the database!");
$q = "Select count(*) from TABLE where nickname='$nickname' and password='". md5($password) ."'";
$query = mysql_query($q);
$num = mysql_result($query,0);
if ($num == "0") {
echo "Wrong nickname/password!";
} else {
SetCookie("User_info", $nickname, time()+3600);
echo "<br><br>Your're now logged on!";
}
mysql_close();
}
?>