-
Notifications
You must be signed in to change notification settings - Fork 0
/
adminlogin.php
135 lines (124 loc) · 4.75 KB
/
adminlogin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
session_start();
?>
<?php
error_reporting(0);
include("dbconnection.php");
$dt = date("Y-m-d");
$tim = date("H:i:s");
?>
<!-- header section -->
<!DOCTYPE html>
<html >
<head >
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<title>Hospital Admin</title>
<link href="assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" type="text/css">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<!-- Custom Css -->
<link href="assets/css/main.css" rel="stylesheet">
<link href="assets/css/login.css" rel="stylesheet">
<!-- Swift Themes. You can choose a theme from css/themes instead of get all themes -->
<link href="assets/css/themes/all-themes.css" rel="stylesheet" />
</head>
<body class="theme-cyan login-page authentication" style="background-image:url('images/login.jpeg');background-repeat: no-repeat;background-size: 100%">
<!-- header section -->
<?php
if(isset($_SESSION['adminid']))
{
echo "<script>window.location='adminaccount.php';</script>";
}
$err='';
if(isset($_POST["submit"]))
{
$sql = "SELECT * FROM admin WHERE loginid='$_POST[loginid]' AND password='$_POST[password]' AND status='Active'";
$qsql = mysqli_query($con,$sql);
if(mysqli_num_rows($qsql) == 1)
{
$rslogin = mysqli_fetch_array($qsql);
$_SESSION['adminid']= $rslogin['adminid'] ;
echo "<script>window.location='adminaccount.php';</script>";
}
else
{
$err = "<div class='alert alert-danger'>
<strong>Oh !</strong> Change a few things up and try submitting again.
</div>";
}
}
?>
<div class="container">
<div id = "err"><?php echo $err;
?></div>
<div class="card-top"></div>
<div class="card">
<h1 class="title"><span>Hospital Management System</span>Login <span class="msg">Sign in to start your session</span></h1>
<div class="col-md-12">
<form method="post" action="" name="frmadminlogin" id="sign_in" onSubmit="return validateform()">
<div class="input-group"> <span class="input-group-addon"> <i class="zmdi zmdi-account"></i> </span>
<div class="form-line">
<input type="text" name="loginid" id="loginid" class="form-control" placeholder="Username" /></div>
</div>
<div class="input-group"> <span class="input-group-addon"> <i class="zmdi zmdi-lock"></i> </span>
<div class="form-line">
<input type="password" name="password" id="password" class="form-control" placeholder="Password" /> </div>
</div>
<div>
<div class="text-center">
<input type="submit" name="submit" id="submit" value="Login" class="btn btn-raised waves-effect g-bg-cyan" /></div>
</div>
</form>
</div>
</div>
</div>
<div class="clear"></div>
<div class="theme-bg"></div>
</div>
</div>
<!-- Jquery Core Js -->
<script src="assets/bundles/libscripts.bundle.js"></script> <!-- Lib Scripts Plugin Js -->
<script src="assets/bundles/vendorscripts.bundle.js"></script> <!-- Lib Scripts Plugin Js -->
<script src="assets/bundles/mainscripts.bundle.js"></script><!-- Custom Js -->
</body>
</html>
<script type="application/javascript">
var alphaExp = /^[a-zA-Z]+$/; //Variable to validate only alphabets
var alphaspaceExp = /^[a-zA-Z\s]+$/; //Variable to validate only alphabets and space
var numericExpression = /^[0-9]+$/; //Variable to validate only numbers
var alphanumericExp = /^[0-9a-zA-Z]+$/; //Variable to validate numbers and alphabets
var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/; //Variable to validate Email ID
function validateform()
{
if(document.frmadminlogin.loginid.value == "")
{
document.getElementById("err").innerHTML ="<div class='alert alert-info'><strong>Heads up!</strong> Please enter Password</div>";
document.frmadminlogin.loginid.focus();
return false;
}
else if(!document.frmadminlogin.loginid.value.match(alphanumericExp))
{
document.getElementById("err").innerHTML ="<div class='alert alert-Warning'><strong>Heads up!</strong> Invalid Password</div>";
document.frmadminlogin.loginid.focus();
return false;
}
else if(document.frmadminlogin.password.value == "")
{
document.getElementById("err").innerHTML ="<div class='alert alert-info'><strong>Heads up!</strong> Should not be empty</div>";
document.frmadminlogin.password.focus();
return false;
}
else if(document.frmadminlogin.password.value.length < 8)
{
document.getElementById("err").innerHTML ="<div class='alert alert-info'><strong>Heads up!</strong> Length should be 8</div>";
document.frmadminlogin.password.focus();
return false;
}
else
{
return true;
}
}
</script>