-
Notifications
You must be signed in to change notification settings - Fork 0
/
doclogin.php
153 lines (145 loc) · 4.18 KB
/
doclogin.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
session_start();
include("includes/header.php");
include("includes/conn.php");
if(isset($_SESSION["login"]))
{
header("Location: index.php");
}
if(isset($_POST["login"]))
{
if($_POST["logtype"]==Administrator)
{
$result = mysqli_query($con,"SELECT * FROM admin WHERE login_id=$_POST[login_id] AND password=$_POST[password]");
//echo "aaa".mysqli_num_rows($result);
if(mysqli_num_rows($result) == 1)
{
while($mqres = mysqli_fetch_array($result))
{
$_SESSION["logtype"] ="Administrator";
$_SESSION["admin_id"] = $mqres[admin_id];
$_SESSION["login_id"] = $mqres[login_id];
$_SESSION["branch_id"] = $mqres[branch_id];
$_SESSION["created_at"] = $mqres[created_at];
$_SESSION["lastlogin"] = $mqres[lastlogin];
}
$dt= date("Y-m-d h:i:s");
mysqli_query($con,"UPDATE admin SET lastlogin=$dt where admin_id=$_SESSION[admin_id]");
$_SESSION["login"] = $_POST[login_id];
header("Location: adminhome.php");
}
else
{
$msg = "<font color =#ff0000>Invalid Login ID and Password";
}
}
if($_POST["logtype"]==Doctor)
{
echo $sql = "SELECT * FROM doctor WHERE login_id=$_POST[login_id] AND password=$_POST[password]";
$result = mysqli_query($con,$sql);
echo mysqli_error($con);
echo "aaa".mysqli_num_rows($result);
if(mysqli_num_rows($result) == 1)
{
while($mqres = mysqli_fetch_array($result))
{
$_SESSION[logtype] ="Doctor";
$_SESSION[doc_id] = $mqres[doc_id];
$_SESSION[branch_id] = $mqres[branch_id];
$_SESSION[login_id] = $mqres[login_id];
$_SESSION[created_at] = $mqres[created_at];
$_SESSION[last_login] = $mqres[last_login];
}
$dt= date("Y-m-d h:i:s");
mysqli_query($con,"UPDATE doctor SET last_login=$dt where doc_id=$_SESSION[doc_id]");
$_SESSION["login"] = $_POST[login_id];
header("Location: dochome.php");
}
else
{
$msg = "Invalid Login ID and Password";
}
}
}
?>
<div id="templatemo_main">
<div id="sidebar" class="float_l">
<img src="images/login.jpg" width="290" height="350" />
</div>
<div id="content" class="float_r">
<?php
if(isset($_SESSION["loginid"]))
{
echo "You already logged in<br>";
?>
<button onclick="window.location.href=patienthome.php">Continue</button>
<?php
}
else
{
?>
<h2>Doctors/ Admin Login</h2>
<script type="application/javascript" >
function validation()
{
if(document.login1.login_id.value == "")
{
alert("Enter Login ID.");
document.login1.login_id.focus();
return false;
}
if(document.login1.password.value == "")
{
alert("Enter Password..");
document.login1.password.focus();
return false;
}
if(document.login1.logtype.value=="")
{
alert("Select login Type.");
return false;
}
}
</script>
<form id="login1" name="login1" method="post" action="" onsubmit="return validation()">
<p> <?php echo $msg; ?></p>
<table width="428" border="0">
<tr>
<td width="119"><label for="login_id">Login ID:</label></td>
<td width="299"><input name="login_id" type="text" id="login_id" size="35" /></td>
</tr>
<tr>
<td>Password</td>
<td><label for="password"></label>
<input name="password" type="password" id="password" size="35" /></td>
</tr>
<tr>
<td height="33">Type</td>
<td><label for="logtype"></label>
<select name="logtype" id="logtype">
<option value="">Select</option>
<option value="Administrator">Administrator</option>
<option value="Doctor">Doctor</option>
</select></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="login" id="login" value="Login" /></td>
</tr>
</table>
<p>
</form>
</p>
<?php
}
?>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</div>
</div>
<div class="cleaner"></div>
</div>
<?php
include("includes/footer.php");
?>