File: /var/www/grapossconnect/admin-dash/index.php
<?php
require_once("_dbconfig.php");
$LOGIN_CREDENTIAL = 'grp_login_credential';
function validate($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$msg = '';
if (isset($_POST['login'])) {
$username = validate($_POST['username']);
$password = validate($_POST['password']);
if($username !="" && $password !==""){
$passwrd = md5($password);
$result = $conn->query("SELECT * FROM $LOGIN_CREDENTIAL WHERE `username`='$username'");
$row_cnt = $result->num_rows;
if ($row_cnt >= 1) {
while ($row = $result->fetch_assoc()) {
if ($passwrd == $row['password']) {
$_SESSION['login_id'] = $row['id'];
$_SESSION['login'] = true;
header("location:dashboard.php");
die();
exit;
} else {
$msg = '<div style="background: red; padding: 5px 11px 8px; font-weight: 700; color: white; border-radius: 0px; text-align:center;">Incorrect Password</div>';
}
}
} else {
$msg = '<div style="background: red; padding: 5px 11px 8px; font-weight: 700; color: white; border-radius: 0px; text-align:center;">Incorrect Username</div>';
}
} else {
$msg = '<div style="background: red; padding: 5px 11px 8px; font-weight: 700; color: white; border-radius: 0px; text-align:center;">Please Enter Username and Password</div>';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title> Login | Sarkari pariksha</title>
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
<link rel="icon" type="image/png" sizes="32x32" href="assets/img/favicon.png">
<link href="assets/css/fontawesome.css" rel="stylesheet" />
<link href="assets/css/vendor.min.css" rel="stylesheet" />
<link href="assets/css/default/app.min.css" rel="stylesheet" />
</head>
<body id="body" class="auth-page" style="background:#f5f8fa url('assets/img/login.png'); background-size: cover; background-position: center center;">
<div class="container-md">
<div class="row vh-100 d-flex justify-content-center">
<div class="col-12 align-self-center">
<div class="card-body">
<div class="row">
<div class="col-lg-4 mx-auto">
<div class="card">
<div class="card-body p-0 auth-header-box" style="background: #eef0f5;">
<div class="text-center p-3">
<a class="logo logo-admin">
<img src="assets/img/logo.png" height="70" alt="logo" class="auth-logo">
</a>
<h4 class="mt-3 mb-1 fw-semibold text-grey font-18">Login Panel</h4>
</div>
</div>
<?php echo $msg; ?>
<div class="card-body pt-0">
<form class="my-4" method="post">
<div class="form-floating mb-20px">
<input type="text" name="username" class="form-control fs-13px h-45px" id="UserName" placeholder="Username" />
<label for="UserName" class="d-flex align-items-center py-0">Enter Username</label>
</div>
<div class="form-floating mb-20px">
<input type="password" name="password" class="form-control fs-13px h-45px" id="password" placeholder="Password" />
<label for="password" class="d-flex align-items-center py-0">Password</label>
</div>
<div class="form-group mb-0 row">
<div class="col-12">
<div class="d-grid mt-3">
<button class="btn btn-primary" name="login" type="submit">LOGIN <i class="fas fa-sign-in-alt ms-1"></i></button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>