

<?php

if (isset($_POST['UserName']) || isset($_POST['Password']))
{

	$linkID = mysql_connect("localhost","root","ktm250") or die("No connection");
	mysql_select_db("newstore") or die("No connection");

	$UserName = mysql_real_escape_string($_POST['UserName']);
	$Password = mysql_real_escape_string($_POST['Password']);

	$query = "SELECT * FROM valid_users WHERE UserName='$UserName' AND Password='$Password'";

	$result = mysql_query($query);

	$num_rows = mysql_numrows($result);

	if($num_rows == 1)
	{
		echo
		"<html>
		<head>
		<title>Forwarding</title>
		<script type='text/javascript'>
				parent.location = 'http://localhost/index.html';
		</script>
		</head>
		</html>";
	}
	else
	{
	echo

		"Invalid Username OR Password...<p>
			Login:<br />
			<form action='login.php' method='post'>
			UserName:<br />
			<input type=\'varchar' name='UserName' size='10' maxlength='32' value='' /><br />
			Password:<br />
			<input type='varchar' name='Password' size='10' maxlength='32' value='' /><br />
			<input type='submit' value='Search!' />
			</form>
		</p>";

	}

	mysql_close();
}
else
{
echo

"<p>
	Login:<br />
	<form action='login.php' method='post'>
	UserName:<br />
	<input type=\'varchar' name='UserName' size='10' maxlength='32' value='' /><br />
	Password:<br />
	<input type='varchar' name='Password' size='10' maxlength='32' value='' /><br />
	<input type='submit' value='Search!' />
	</form>
</p>";

}

?>
