-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.php
286 lines (258 loc) · 11.8 KB
/
index.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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href='https://unpkg.com/[email protected]/css/boxicons.min.css' rel='stylesheet'>
<link rel="stylesheet" href="style5.css">
<script>
var check = function () {
if (document.getElementById('password').value ==
document.getElementById('cpassword').value) {
document.getElementById('message').style.color = '#5dd05d';
document.getElementById('message').innerHTML = 'Matched';
} else {
document.getElementById('message').style.color = '#f55252';
document.getElementById('message').innerHTML = 'Not Matching';
}
}
function alphaOnly(event) {
var key = event.keyCode;
return ((key >= 65 && key <= 90) || key == 8 || key == 32);
};
function redirectToPatientLogin() {
window.location.replace("index.php");
return false;
}
function redirectToDoctorLogin() {
window.location.replace("doctor-login.php");
return false;
}
function redirectToAdminLogin() {
window.location.replace("admin-login.php");
return false;
}
window.onload = function () {
var formSubmitted = localStorage.getItem('formSubmitted');
if (formSubmitted === 'true') {
var formId = localStorage.getItem('lastSubmittedForm');
if (formId) {
showForm(formId);
}
} else {
showForm('loginPatient'); // Show the patient registration form by default
}
};
function submitForm(formId) {
localStorage.setItem('formSubmitted', 'true');
localStorage.setItem('lastSubmittedForm', formId);
return true;
}
</script>
</head>
<body>
<div class="wrapper">
<nav class="nav">
<div class="nav-logo">
<a href="index.php"><img src="logo.png" alt="">
<span>MediBook: Appointment Scheduler</span>
</div>
<div class="nav-menu" id="navMenu">
<ul>
<li><a href="index.php" class="mobile-only">Patient</a></li>
<li><a href="doctor-login.php" class="mobile-only">Doctor</a></li>
<li><a href="admin-login.php" class="mobile-only">Admin</a></li>
</ul>
</div>
<div class="nav-button">
<button class="btn white-btn" id="registerBtn" onclick="redirectToPatientLogin()">Patient</button>
<button class="btn white-btn" id="registerBtn" onclick="redirectToDoctorLogin()">Doctor</button>
<button class="btn white-btn" id="registerBtn" onclick="redirectToAdminLogin()">Admin</button>
</div>
<div class="nav-menu-btn">
<i class="bx bx-menu" onclick="myMenuFunction()"></i>
</div>
</nav>
<div class="form-box">
<div class="register-container" id="loginPatient">
<div class="top">
<header>Register as a patient</header>
</div>
<form action="function2.php" method="POST" onsubmit="return validateForm()">
<div class="two-forms">
<div class="input-box">
<input type="text" class="form-control" placeholder="First Name *" name="fname"
onkeydown="return alphaOnly(event);" />
<i class="bx bx-user"></i><br><br>
</div>
<div class="input-box">
<input type="text" class="form-control" placeholder="Lastname *" name="lname"
onkeydown="return alphaOnly(event);" />
<i class="bx bx-user"></i><br><br>
</div>
</div>
<div class="two-forms">
<div class="input-box">
<input type="email" class="form-control" placeholder="Your Email *" name="email" />
<i class="bx bx-envelope"></i><br><br>
</div>
<div class="input-box">
<input type="tel" minlength="10" maxlength="10" name="contact" class="form-control"
placeholder="Your Phone *" />
<i class='bx bx-dots-horizontal-rounded'></i><br><br>
</div>
</div>
<div class="two-forms">
<div class="input-box">
<input type="password" class="form-control" placeholder="Password *" id="password"
name="password" onkeyup='check();' />
<i class="bx bx-lock-alt"></i><br><br>
</div>
<div class="input-box">
<input type="password" class="form-control" id="cpassword" placeholder="Confirm Password *"
name="cpassword" onkeyup='check();' /><span id='message'></span>
<i class="bx bx-lock-alt"></i><br><br>
</div>
</div>
<div class="two-col">
<div class="one">
<label class="radio inline">
<input type="radio" name="gender" value="Male" checked>
<span> Male </span>
</label>
<label class="radio inline">
<input type="radio" name="gender" value="Female">
<span>Female </span>
</label>
</div>
</div>
<br>
<div class="input-box">
<input type="submit" class="btnRegister" name="patsub1"
onclick="return checklen() && validateForm();" value="Register" />
</div><br>
</form>
<div class="input-box">
<button class="btnlogin" onclick="window.location.href='patient-login.php';">Login as
patient</button>
</div>
</div>
<!-- Doctor -->
<div class="register-container" id="loginDoctor">
<div class="top">
<header>Login as Doctor</header>
</div>
<form action="function1.php" method="POST" onsubmit="return validateDoctorForm();">
<div class="two-forms">
<div class="input-box">
<input type="text" class="form-control" placeholder="User Name *" name="username3" />
<i class="bx bx-user"></i><br><br>
</div>
<div class="input-box">
<input type="password" class="form-control" placeholder="Password *" name="password3" />
<i class="bx bx-lock-alt"></i>
</div>
</div>
<div class="input-box">
<input type="submit" class="btnRegister" name="docsub1" value="Login" />
</div>
</form>
</div>
<!-- Admin -->
<div class="register-container" id="loginAdmin">
<div class="top">
<header>Login as Admin</header>
</div>
<form action="function3.php" method="POST" onsubmit="return validateAdminForm();">
<div class="two-forms">
<div class="input-box">
<input type="text" class="form-control" placeholder="User Name *" name="username1" />
<i class="bx bx-user"></i><br><br>
</div>
<div class="input-box">
<input type="password" class="form-control" placeholder="Password *" name="password2" />
<i class="bx bx-lock-alt"></i><br><br>
</div>
</div>
<div>
<input type="submit" class="btnRegister" name="adsub" value="Login" />
</div>
</form>
</div>
</div>
</div>
<script>
function myMenuFunction() {
var i = document.getElementById("navMenu");
if (i.className === "nav-menu") {
i.className += " responsive";
} else {
i.className = "nav-menu";
}
}
function showForm(formId) {
var forms = document.getElementsByClassName("register-container");
for (var i = 0; i < forms.length; i++) {
forms[i].style.display = "none";
}
var form = document.getElementById(formId);
form.style.display = "block";
}
function validateForm() {
// Get the values from the form
var firstName = document.getElementsByName("fname")[0].value;
var lastName = document.getElementsByName("lname")[0].value;
var email = document.getElementsByName("email")[0].value;
var contact = document.getElementsByName("contact")[0].value;
// Check if all fields are filled
if (firstName === "" || lastName === "" || email === "" || contact === "") {
alert("Please fill in all fields.");
return false;
}
// Check if the email field is not empty and has a valid email format
if (email !== "") {
var emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(email)) {
alert("Please enter a valid email address.");
return false;
}
}
// Check if the contact field is not empty and has a length of 10 digits
if (contact !== "") {
var contactRegex = /^\d{10}$/;
if (!contactRegex.test(contact)) {
alert("Please enter a 10-digit contact number.");
return false;
}
}
function checklen() {
var pass1 = document.getElementById("password");
if (pass1.value.length < 6) {
alert("Password must be at least 6 characters long. Try again!");
return false;
}
}
return true; // Form is valid and can be submitted
}
function validateDoctorForm() {
var username = document.getElementsByName("username3")[0].value;
var password = document.getElementsByName("password3")[0].value;
if (username === "" || password === "") {
alert("Please fill in all fields.");
return false;
}
return true;
}
function validateAdminForm() {
var username = document.getElementsByName("username1")[0].value;
var password = document.getElementsByName("password2")[0].value;
if (username === "" || password === "") {
alert("Please fill in all fields.");
return false;
}
return true;
}
</script>
</body>
</html>