I created this login page that checks whether the entered username and password matches a record in the users table. But whenever I click on the submit button, nothing happens. What is the error? Here is my code:
<?php
session_start();
include 'dbconnect.php';
if (isset($_POST['submit'])) {
if (isset($_POST['tsmUsername'])) {
$username=$_POST['tsmUsername'];
$_SESSION['tsmUserName']=$username;
$password=$_POST['tsmPassword'];
$sql="SELECT * FROM users cust_registration WHERE custName='$username' AND custPass='$password' LIMIT 1";
$result=mysql_query($dbconnect,$sql);
if(mysql_num_rows($result)==1)
{
echo "You have successfully logged in";
}
else{
echo "Invalid";
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title> THE CAR PARK</title>
<centre><div class="a1">
<h3 style="color:crimson" align="centre"> WELCOME TO THE </h3>
</div></centre>
<centre> <div class="a2">
<h1 style="color:crimson" align="centre"> PARK MARK </h1>
</div></centre>
<hr> <br>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Coding Cage - Login & Registration System</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body background="user4.png" height="auto" width="auto" bgcolor = "#FFFFFF">
<div class="form">
<div class="container">
<div align="center" id="login-form">
<form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" autocomplete="off">
<div class="col-md-12">
<div class="form-group">
<h2 style="color:crimson" class="">LOGIN</h2>
</div>
<div class="form-group">
<hr />
</div>
<?php
if ( isset($errMSG) ) {
?>
<div class="form-group">
<div class="alert alert-<?php echo ($errTyp=="success") ? "success" : $errTyp; ?>">
<span class="glyphicon glyphicon-info-sign"></span> <?php echo $errMSG; ?>
</div>
</div>
<?php
}
?>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
<centre><p style="color:crimson">Username</p> <input type="text" name="tsmUsername" class="form-control" placeholder="Enter Name" maxlength="50" value="<?php echo $name ?>" /></centre>
</div>
<span class="text-danger"><?php echo $nameError; ?></span>
</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
<centre><p style="color:crimson">Password</p><input type="password" name="tsmPassword" class="form-control" placeholder="Enter Password" maxlength="15" /></centre>
</div>
<span class="text-danger"><?php echo $passError; ?></span>
</div>
<div class="form-group">
<hr />
</div>
<tr> <div class="form-group">
<centre><button type="submit" class="btn btn-block btn-primary" name="submit">log in</button></centre>
</div>
<div class="hd5">
<button><a href="welcome.php">Back To Home>></a></button>
<button><a href="cust_register.php">Customer registration</a></button>
<button><a href="location.php">Location</a></button>
<button><a href="parking.php">Parking</a></button>
<button><a href="accounts.php">Accounts</a></button>
</div>
<hr />
</tr>
</div>
</form>
</div>
</div>
</div>
</body>
<header>
<h5 align="right" style=color:antiquewhite>Designed by: john</h5>
</header>
</html>
<?php ob_end_flush(); ?>