-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
219 lines (195 loc) · 8.19 KB
/
index.php
File metadata and controls
219 lines (195 loc) · 8.19 KB
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
<?php
session_start();
if (isset($_SESSION["email"])) {
header("Location: request.php");
exit();
}
if (isset($_POST["login"])) {
$email = $_POST["email"];
$pass = $_POST["password"];
$conn = mysqli_connect('localhost', 'root', '', 'aqi');
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT * FROM user WHERE email = '$email'";
$result = mysqli_query($conn, $sql);
if ($result && mysqli_num_rows($result) == 1) {
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
if (password_verify($pass, $row['pass'])) {
$_SESSION["email"] = $email;
echo "You are now redirected...";
header("refresh: 2; url = request.php");
exit();
} else {
echo "Incorrect password. Redirecting back...";
header("refresh: 2; url = index.php");
exit();
}
} else {
echo "User not found. Redirecting back...";
header("refresh: 2; url = index.php");
exit();
}
}
if ($_SERVER["REQUEST_METHOD"] == "POST" && !isset($_POST["login"])) {
echo "Please fill in email and password.";
header("refresh: 2; url = index.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Air Quality Index</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div style="text-align: center;">
<p>
<img src="aqi.jpg" alt="The Flexbox" height="70px" width="70px" style="border-radius: 60%; border: solid;">
</p>
<h1>AQI</h1>
</div>
<div class="flex-container">
<div id="flex1">
<h2>Registration Form</h2><br>
<form id="regForm" method="post" action="process.php" onsubmit="return validateForm()">
<label for="name">Name</label>
<input type="text" id="name" name="name">
<span class="error-message" id="nameError"></span>
<label for="email">Email</label>
<input type="email" id="email" name="email">
<span class="error-message" id="emailError">
<?php
if (isset($_GET['error']) && $_GET['error'] === 'emailexists') {
echo "Email already registered. Please use a different email.";
}
?>
</span>
<label for="password">Password</label>
<input type="password" id="password" name="password">
<span class="error-message" id="passwordError"></span>
<label for="confirm_password">Confirm Password</label>
<input type="password" id="confirm_password" name="confirm_password">
<span class="error-message" id="confirmPasswordError"></span>
<label for="dob">Date of Birth</label>
<input type="date" id="dob" name="dob">
<span class="error-message" id="dobError"></span>
<label for="country">Country</label>
<select id="country" name="country">
<option value="">Select your country</option>
<option value="USA">United States</option>
<option value="UK">United Kingdom</option>
<option value="Canada">Canada</option>
<option value="Australia">Australia</option>
<option value="Bangladesh">Bangladesh</option>
<option value="India">India</option>
<option value="Other">Other</option>
</select>
<span class="error-message" id="countryError"></span>
<label>Gender</label>
<div class="radio-group">
<input type="radio" id="male" name="gender" value="Male">
<label for="male">Male</label>
<input type="radio" id="female" name="gender" value="Female">
<label for="female">Female</label>
</div>
<span class="error-message" id="genderError"></span>
<label for="color">Favorite Color</label>
<input type="color" id="color" name="color">
<span class="error-message" id="colorError"></span>
<label for="opinion">Your Opinion</label>
<textarea id="opinion" name="opinion" placeholder="Share your thoughts..."></textarea>
<span class="error-message" id="opinionError"></span>
<div id="terms" class="terms-container">
<input type="checkbox" id="agreeCheckbox" name="agreeCheckbox">
<label for="agreeCheckbox">I agree to the <a href="#top">Terms and Conditions</a></label>
</div>
<span class="error-message" id="termsError"></span>
<button type="submit" name="submit">Register</button>
</form>
</div>
<div class="right-side">
<div id="flex3" class="flex">
<h3 style="color: aqua;">LOGIN</h3>
<form id="loginform" method="post" action="">
<label for="email">Email</label>
<input type="email" id="email" name="email" required>
<label for="password">Password</label>
<input type="password" id="password" name="password" required>
<button type="submit" name="login">Login</button>
</form>
</div>
<div id="flex4" class="flex">
<div id="loginOverlay">
<div id="overlayContent">
<h2>Login Required</h2>
</div>
</div>
<div id="innerBox">
<div class="refresh-container" id="refreshContainer">
<img src="icon.jpg" alt="Refresh" id="refreshGif">
<span id="refreshLabel">Refresh</span>
</div>
<table>
<thead>
<tr>
<th>City</th>
<th>AQI</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1, Col 1</td>
<td>Row 1, Col 2</td>
</tr>
<tr>
<td>Row 2, Col 1</td>
<td>Row 2, Col 2</td>
</tr>
<tr>
<td>Row 3, Col 1</td>
<td>Row 3, Col 2</td>
</tr>
<tr>
<td>Row 4, Col 1</td>
<td>Row 4, Col 2</td>
</tr>
<tr>
<td>Row 5, Col 1</td>
<td>Row 5, Col 2</td>
</tr>
<tr>
<td>Row 6, Col 1</td>
<td>Row 6, Col 2</td>
</tr>
<tr>
<td>Row 7, Col 1</td>
<td>Row 7, Col 2</td>
</tr>
<tr>
<td>Row 8, Col 1</td>
<td>Row 8, Col 2</td>
</tr>
<tr>
<td>Row 9, Col 1</td>
<td>Row 9, Col 2</td>
</tr>
<tr>
<td>Row 10, Col 1</td>
<td>Row 10, Col 2</td>
</tr>
<tr>
<td>Row 11, Col 1</td>
<td>Row 11, Col 2</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script src="validation.js"></script>
</body>
</html>