Code: Select all
<?
session_start();
?>
<html>
<head>
<title>template</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="templates/site.css" type="text/css">
</head>
<body bgcolor="#E5E5E5" topmargin="5" leftmargin="5" rightmargin="5" bottommargin="5">
<div align="center">
<table width="100%" height="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#999999" bgcolor="#FFFFFF">
<tr valign="top">
<td> <table width="100%" height="150" border="0" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
</tr>
<tr>
<td height="50">
<table width="300" height="50" align="center">
<tr>
<td>
<?
//start of submit conditions
if (isset($_POSTї'submit']))
{
require_once('dbconnect.php');
$message = NULL;
$message = NULL;
//verify username
if (empty($_POSTї'username']))
{
$un = FALSE;
$message .= 'Please enter your username!<br>';
}
else
{
$un = stripslashes($_POSTї'username']);
}
//verify password
if (empty($_POSTї'password']))
{
$pw = FALSE;
$message .= 'Please enter your password!<br>';
}
else
{
$pw = stripslashes($_POSTї'password']);
}
//if username and password OK...
if ($un && $pw)
{
$query = "SELECT userID, firstname, lastname FROM users WHERE username='$un' AND password='$pw'";
$result = @mysql_query ($query);
$row = mysql_fetch_array ($result, MYSQL_NUM);
if ($row)
{
$_SESSIONї'lastname'] = $rowї2];
$_SESSIONї'firstname'] = $rowї1];
$_SESSIONї'userID'] = $rowї0];
header ("Location: http://" . $_SERVERї'HTTP_HOST'] . dirname($_SERVERї'PHP_SELF']) . "/index.php");
exit();
}
else
{
$message = 'The username and password entered do not match.<br>';
}
mysql_close();
}
else
{
$message .= 'Try again.<br>';
}
}//end of submit conditions
if (isset($message))
{
echo '<font color="red">', $message, '</font>';
}
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="100%" height="200" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><table width="300" height="200" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="336699">
<tr>
<td><table width="100%" height="20" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
</tr>
</table>
<table width="298" height="160" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="ffffff">
<tr>
<td>
<!--start-->
<table width="100%" align="center" bgcolor="#ffffff">
<form action="<? $_SERVERї'PHP_SELF']; ?>" method="post">
<tr>
<td width="30%"><b>username:</b></td>
<td width="70%"><input type="text" name="username" value="<? if (isset($_POSTї'username'])) echo $_POSTї'username']; ?>"></td>
</tr>
<tr>
<td width="30%"><b>password:</b></td>
<td width="70%"><input type="password" name="password" value="<? if (isset($_POSTї'password'])) echo $_POSTї'password']; ?>"></td>
</tr>
<tr>
<td width="30%"></td>
<td width="70%">
<table width="100%" bgcolor="#ffffff" cellpadding="0" cellspacing="0">
<tr bordercolor="#ffffff">
<td width="30%"><input type="submit" name="submit" value="login"></td>
<td width="40%"><p align="right"><b><a href="register.php" class="under">register</a></b></p></td>
<td width="30%"></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
<!--end-->
</td>
</tr>
</table>
<table width="100%" height="20" border="0" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</div>
</body>
</html>