I am making this simple code for authentication of a user. the page with the form is : >login.php. with the following code.
login.php :
<html>
<body>
<div style="position:absolute;left:300px;top:300px;width:300px;height:100px;z-index:9;>
<form name="form1" method="POST" action="check.php">
Username:<br />
<input type="text" name="Username" />
<br /><br />
Password:<br />
<input type="password" name="Password" />
<br /><br /><br/>
<input type=button onClick="location.href='check.php'" value='Continue' name='continue'/>
</form>
</div>
</body>
</html>
the form field values are being used in the next php page with following code:
check.php :
<?php
session_start();
$con = mysql_connect("localhost", "root", "");
mysql_select_db("aviation", $con) or die(mysql_error());
if (isset($_POST['continue'])) {
$userName = $_POST[Username];
$passWord = $_POST[Password];
mysql_select_db('aviation');
$query = "select * from users where Username='" . $userName . "'and Password='" . $passWord . "'";
$result = mysql_query($query, $con);
if (!$result) {
die('Could not enter data: ' . mysql_error());
}
$rows = mysql_num_rows($result);
if ($rows == 1) {
$_SESSION['Username'];
$_SESSION['Password'];
echo "Successful";
echo "<BR>";
echo "You are authorized to update the status of Bays.";
echo "<BR>";
$Msg = "Redirecting....";
echo '<script type="text/javascript">
alert("' . $Msg . '");
</script>';
header("location:upbstatus.php");
} elseif ($userName == "" || $passWord == "") {
$errorMsg = "Data was not entered <br/> Enter Username and Password";
echo '<script type="text/javascript">
alert("' . $errorMsg . '");
</script>';
else {
$errorMsg = "Data Does Not Match <br/> Re-Enter Username and Password";
$errorMsg = "Data was not entered <br/> Enter Username and Password";
echo '<script type="text/javascript">
alert("' . $errorMsg . '");
</script>';
}
} else {
echo (" =============== not SET ===============");
}
?>
It always return : =============== not SET ===============
I am so stuck at why is this happening.Can anybody help please? It'l be appreciated.
Thankyou.