This is a simple PHP script that uses a MySQL table to store the login/password. I have included some extra code which is to be put into some sort of include file which is in turn to be included on every page you want to be protected (ie not viewable unless logged in via the login screen). Note: I know that this line: $msg = "<meta http-equiv=\"Refresh\" content=\"0;url=./mainpage.php\">"; is real lame but it's the only thing I could think of that is fairly compatable. The reason I did not use header() here is because using header() after setcookie() is not compatible with some versions of IE.
<?
if($username && $password) {
mysql_connect() or die ( "Whoops");
$password = md5($password);
$sql = "select * from login where username='$username'";