-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
177 lines (168 loc) · 4.46 KB
/
login.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?php
session_start();
include("includes/header.php");
include("includes/conn.php");
if(isset($_SESSION["login"]))
{
header("Location: patienthome.php");
}
if(isset($_POST["login"]))
{
$sqllogin="SELECT * FROM patient
WHERE email_id=$_POST[email_id] AND password=$_POST[password]";
$result = mysqli_query($con,$sqllogin);
//echo.mysqli_num_rows($result);
if(mysqli_num_rows($result) == 1)
{
while($mqres = mysqli_fetch_array($result))
{
$_SESSION["logtype"] ="Patient";
$_SESSION["pat_id"] = $mqres[pat_id];
$_SESSION["email_id"] = $mqres[email_id];
$_SESSION["created_at"] = $mqres[created_at];
}
$_SESSION["login"] = $_POST[email_id];
header("Location: patienthome.php");
}
else
{
$msg = "<b><font color=#FF0000>Invalid Login ID and Password";
}
}
?>
<div id="templatemo_main">
<div id="sidebar" class="float_l">
<div class="sidebar_box"><span class="bottom"></span>
<h3>New Users</h3>
<a href="register.php"><img src="images/register.jpg" width="238" height="225" /></a> </div>
</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>Login</h2>
<script type="application/javascript" >
function validation()
{
//Validation for Email ID
em = document.login.email_id.value;
pos1 = em.indexOf("@")
pos = em.indexOf(" ")
pos2 = (pos1+1)
server = em.substring(pos2);
server_pos = server.lastIndexOf(".")
reqtype = server.substring(server_pos+1)
type_end = reqtype.substring(reqtype.length-1)
//Email ID
if(em == "")
{
document.login.email_id.focus();
alert("Email cannot be blank");
return false;
}
else if(em.length<8)
{
document.login.email_id.focus();
alert("Email length cannot be less than 8 characters");
return false;
}
else if(em.indexOf("@")==-1)
{
document.login.email_id.focus();
alert("The Email Address must contain @ sign");
return false;
}
else if(pos1<1)
{
document.login.email_id.focus();
alert("Email address cannot start with @ sign");
return false;
}
else if(em.indexOf(".")==-1)
{
document.login.email_id.focus();
alert("The Email Address must contain . sign");
return false;
}
else if(pos!=-1)
{
document.login.email_id.focus();
alert("The Email Address cannot contain spaces");
return false;
}
else if(server.indexOf("@")!=-1)
{
document.login.email_id.focus();
alert("A valid Email must contain only one @ sign");
return false;
}
else if(server.indexOf(".")==0)
{
document.login.email_id.focus();
alert("There should some text between @ and . sign");
return false;
}
else if(reqtype=="")
{
document.login.email_id.focus();
alert("Email Id should end with character(like .com,.net,.org)");
return false;
}
else if(type_end.toUpperCase()<"A" || type_end.toUpperCase()>"Z")
{
document.login.email_id.focus();
alert("Email Id should not end with number or symbol");
return false;
}
if(document.login.password.value == "")
{
alert("Enter Password..");
document.login.password.focus();
return false;
}
}
</script>
<form id="login" name="login" method="post" action="" onsubmit="return validation()">
<p> <?php echo $msg; ?></p>
<table width="428" border="0">
<tr>
<td width="119"><label for="email_id">Email ID:</label></td>
<td width="299"><input name="email_id" type="text" id="email_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 colspan="2" align="center"><input type="submit" name="login" id="login" value="Login" /></td>
</tr>
<tr>
<td colspan="2" align="center"><strong><a href="forgotpassword.php">Forgot Password</a></strong></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");
?>