I get this message:
Fatal error: Uncaught PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Password' in 'field list' in C:\xampp\htdocs\eCommerce\admin\index.php:26 Stack trace: #0 C:\xampp\htdocs\eCommerce\admin\index.php(26): PDOStatement->execute(Array) #1 {main} thrown in C:\xampp\htdocs\eCommerce\admin\index.php on line 26
It says that the error comes from this line:
$stmt->execute(array($username, $hashedPass));
<?php
session_start();
$noNvabar = '';
if(isset($_SESSION['Username'])){
header('Location: dashboard.php');//Redirect to dashboard page
}
include 'init.php';
// Check if the user coming from an http post request
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$username = $_POST['user'];
$password = $_POST['pass'];
$hashedPass = sha1($password);
// Check if the user exist in the database
$stmt = $con->prepare("SELECT Username, Password FROM users WHERE Username = ? AND Password = ?");
$stmt->execute(array($username, $hashedPass));
$count = $stmt->rowCount();
// If count > 0 this means the database contains record about this username
if ($count > 0) {
echo 'welcome' . $username;
$_SESSION['Username'] = $username; // Register Session Nmae
header('Location: dashboard.php'); // Redirect to dashboard page
exit();
}
}
?>
<form class="login" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
<h4 class="text-center">Admin Login </h4>
<input class="form-control" type="text" name="user" placeholder="Username" autocomplete="off" />
<input class="form-control" type="password" name="pass" placeholder="Password" autocomplete="new-Password" />
<input class="btn btn-primary btn-block " type="submit" value="login" />
</form>
<?php
include $tbl . 'footer.php';
?>