<?
	include("include/common.php");

	if( $_POST['username'] && $_POST['password'] ){
		$failed = 1;
		$username = $_POST['username'];
		$password = $_POST['password'];
		$query = "SELECT * FROM users WHERE username='$username' AND password='$password'";
#		echo $query;
		$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
		if ( ($result) && (mysql_num_rows($result) > 0) ){
			$row = mysql_fetch_object($result);
			$adlogin = $row->username;
			$myname = $row->username;
			$adpassword = $row->password;
			$myuid = $row->uid;
#			echo $adlogin." ----".$adpassword."<br>";
			if ( ($username != $adlogin) || ($password != $adpassword) ){
				$failed = 1;
			}else{
				$failed = 0;
				$loggedin = 1;
				session_register("loggedin");
				session_register("myuid");
				session_register("myname");
			}
		}else{
			$failed = 1;
		}
	}
	if($loggedin){
		ob_start();
		header("Location: account.php");
	}
	include("include/header.php");
?>
<p><font face=arial size=3>
<form action="login.php" method="POST">
<input type="hidden" name="action" value="login"><font face="arial" size="2"><b>Username</b><br>
<input type=text name=username size=30 tabindex="1" maxlength="12"><i>[type in your username]</i></font><br>
<font face="arial" size="2"><br>
<b>Password</b><br>
<input type=password name=password size=30 tabindex="2" maxlength="12"><i>[type in your password]</i></font><br>
<br>
<font face="arial" size="2"><input type="submit" name="" value="Login" tabindex="4" style="background-color:#e5e5e5; color:#000000; font-family:Verdana,Arial; font-weight: bold; font-size: 11px; border-left: 1 solid #a0a0a0; border-top: 1 solid #a0a0a0; border-right: 1 solid #000000; border-bottom: 1 solid #000000; padding: 2 2 2 2; outline: #a0a0a0 solid 2px;">
<br><br>
</font>
<table border="0" cellpadding="0" cellspacing="0" width="178">
<tr height="19">
	<td height="19" valign="top">
		<font face="arial" size="2"><b><a href="mailto:<?=$adminemail?>?subject=<?=$sitename?>/Password"><b>Forgot Your Password?</b></a></b></font>
	</td>
</tr>
<tr height="18">
	<td valign="bottom" height="18">
		<font face="arial" size="2"><b><a href="/join.php"><b>Register New Account!</b></a></b></font>
	</td>
</tr>
</table>
</form>
</font></p>
<?
	include("include/footer.php");
?>