CasperSecurity
<?php
include('../includes/connection.php');
session_start();
if (isset($_SESSION['id'])):
header("location:dashboard.php");
endif;
if(isset($_POST['submit']))
{
$captcha = $connect->real_escape_string($_POST['recaptchaResponse']);
// print_r($captcha);
// die();
$uname=$connect->real_escape_string($_POST["uname"]);
$pwd=$connect->real_escape_string(md5($_POST['pwd']));
$vercode=$connect->real_escape_string($_POST['vercode']);
$vercode1=$_SESSION["vercode"];
if($vercode != $vercode1){
$msg="incorrect Captcha Code";
print "<script>";
print "self.location = 'index.php?strmsg=$msg';";
print "</script>";
}else{
$sql = "SELECT * FROM admin_login WHERE uname='$uname' AND pwd='$pwd'";
// print_r($sql);
// die();
$result = db_query($sql);
if ($result->num_rows > 0)
{
while($row = $result->fetch_assoc())
{
//echo "Login Successfully";
$_SESSION['id']=$row["id"];
header("location:dashboard.php");
}
}
else {
$msg="incorrect Username or Password";
print "<script>";
print "self.location = 'index.php?strmsg=$msg';";
print "</script>";
}
}
}
?>
<html lang="en">
<head>
<?php include("css.php"); ?>
</head>
<body class="jumbo-page">
<main class="admin-main ">
<div class="container-fluid">
<div class="row ">
<div class="col-lg-4 bg-white">
<div class="row align-items-center m-h-100">
<div class="mx-auto col-md-8">
<?php include("admin_logo.php"); ?>
<h3 class="text-center p-b-20 fw-400">Login</h3>
<?php if (isset($_GET['strmsg'])) { ?><center><span style="color:red;"><?php echo $_GET['strmsg']; ?></span></center><?php } ?>
<?php if ($_COOKIE['msg']) { ?>
<div class="alert alert-danger" style="color:red;">
<strong></strong> <?php print str_replace("+", " ", $_COOKIE['msg']); ?>
</div>
<?php } ?>
<form action="index.php" method="post" name="form1">
<input type="hidden" name="recaptchaResponse" id="recaptchaResponse">
<div class="form-row">
<div class="form-group floating-label col-md-12">
<label>User Name</label>
<input type="text" class="form-control" placeholder="User Name" name="uname" autocomplete="off" required>
</div>
<div class="form-group floating-label col-md-12">
<label>Password</label>
<input type="password" class="form-control" placeholder="Password" name="pwd" autocomplete="off" required>
</div>
<div class="form-group floating-label col-md-8">
<label>Captcha</label>
<input type="text" class="form-control" placeholder="Enter Code" autocomplete="off" name="vercode" required>
</div>
<div class="form-group floating-label col-md-4">
<img src="captcha.php" style="width: 60px; margin-right:15px;">
</div>
</div>
<button type="submit" name="submit" class="btn btn-primary btn-block btn-lg">Login</button>
<!-- <a href="forget.php"><span style="margin-top: 10px; color: red;">Click To Reset Your Password</span></a>-->
</form>
</div>
</div>
</div>
<div class="col-lg-8 d-none d-md-block bg-cover" style="background-image: url('assets/img/login.svg');"></div>
</div>
</div>
</main>
<?php include("js.php");
// $sitekey='6Ld5ZLQaAAAAAIGP6e8mtfGBkyZvh-z1IhASP_Tr';
?>
<script>
grecaptcha.ready(function () {
grecaptcha.execute('<?php print $sitekey; ?>',{action:'doctor_login.php'}).then(function(token){
var recaptchaResponse = document.getElementById('recaptchaResponse');
recaptchaResponse.value = token;
});
});
</script>
</body>
</html>