2
2
session_start ();
3
3
include "db.php " ;
4
4
5
-
6
-
7
5
if ($ _SERVER ['REQUEST_METHOD ' ] == 'POST ' ) {
8
6
9
- // Get the user input
10
- $ email = $ _POST ['email ' ];
11
- $ password = $ _POST ['password ' ];
7
+ // Get the user input and escape it for security
8
+ $ email = $ conn -> real_escape_string ( $ _POST ['email ' ]) ;
9
+ $ password = $ conn -> real_escape_string ( $ _POST ['password ' ]) ;
12
10
13
- // Query to check if the username and password are correct
11
+ // Query to check if the email and password are correct
14
12
$ result = $ conn ->query ("SELECT * FROM register WHERE email=' $ email' AND password=' $ password' " );
15
13
16
14
// If a match is found, set the session
17
15
if ($ result ->num_rows > 0 ) {
18
16
$ _SESSION ['email ' ] = $ email ; // Set session variable
19
-
20
17
header ("Location: index.php " ); // Redirect to the dashboard or home page
21
-
18
+ exit ();
22
19
} else {
23
- die ("Error: The email ' $ email' doesn'nt exist " );
20
+ // Store the error message in a variable to use in the HTML
21
+ $ error_message = "Invalid email or password! " ;
24
22
}
25
23
}
26
-
27
24
?>
28
25
29
26
27
+
28
+
29
+
30
30
<!DOCTYPE html>
31
31
<html lang="en">
32
32
35
35
<meta content="width=device-width, initial-scale=1.0" name="viewport">
36
36
37
37
<title>Login</title>
38
- <meta content="" name="description">
39
- <meta content="" name="keywords">
40
-
41
- <!-- Favicons -->
42
- <link href="assets/img/favicon.png" rel="icon">
43
- <link href="assets/img/apple-touch-icon.png" rel="apple-touch-icon">
44
38
45
39
<!-- Google Fonts -->
46
- <link href="https://fonts.gstatic.com" rel="preconnect">
47
- <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Nunito:300,300i,400,400i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">
40
+ <link href="https://fonts.googleapis.com/css?family=Open+Sans|Nunito|Poppins" rel="stylesheet">
48
41
49
42
<!-- Vendor CSS Files -->
50
43
<link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
51
- <link href="assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
52
- <link href="assets/vendor/boxicons/css/boxicons.min.css" rel="stylesheet">
53
- <link href="assets/vendor/quill/quill.snow.css" rel="stylesheet">
54
- <link href="assets/vendor/quill/quill.bubble.css" rel="stylesheet">
55
- <link href="assets/vendor/remixicon/remixicon.css" rel="stylesheet">
56
- <link href="assets/vendor/simple-datatables/style.css" rel="stylesheet">
57
44
58
-
59
- <!--ALERTIFY CSS-->
60
- <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/alertifyjs@1.14.0/build/css/alertify.min.css" />
61
- <!-- Bootstrap theme -->
62
- <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/alertifyjs@1.14.0/build/css/themes/bootstrap.rtl.min.css" />
45
+ <!-- ALERTIFY CSS -->
46
+ <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/alertifyjs@1.14.0/build/css/alertify.min.css"/>
47
+ <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/alertifyjs@1.14.0/build/css/themes/bootstrap.rtl.min.css"/>
63
48
64
49
<style>
65
50
.w-100 {
70
55
71
56
<!-- Template Main CSS File -->
72
57
<link href="assets/css/style.css" rel="stylesheet">
73
- <style>
74
- .logo img {
75
- max-height: 50px;
76
- margin-right: 11px;
77
- }
78
- </style>
79
58
</head>
80
59
81
60
<body>
82
61
83
62
<main>
84
63
<div class="container">
85
-
86
64
<section class="section register min-vh-100 d-flex flex-column align-items-center justify-content-center py-4">
87
65
<div class="container">
88
66
<div class="row justify-content-center">
93
71
<img src="assets/img/logo3.png" alt="">
94
72
<span class="d-none d-lg-block">FingerLog</span>
95
73
</a>
96
- </div><!-- End Logo -->
74
+ </div>
97
75
98
76
<div class="card mb-3">
99
-
100
77
<div class="card-body">
101
-
102
78
<div class="pt-4 pb-2">
103
79
<h5 class="card-title text-center pb-0 fs-4">Login to Your Account</h5>
104
80
<p class="text-center small">Enter your email & password</p>
105
81
</div>
106
82
107
83
<form class="row g-3 needs-validation" method="POST" action="">
108
-
109
84
<div class="col-12">
110
85
<label for="yourEmail" class="form-label">Your Email</label>
111
86
<input type="email" name="email" class="form-control" id="yourEmail" required>
112
- <div class="invalid-feedback">Please enter a valid Email adddress !</div>
87
+ <div class="invalid-feedback">Please enter a valid Email address !</div>
113
88
</div>
114
89
115
90
<div class="col-12">
116
91
<label for="yourPassword" class="form-label">Password</label>
117
92
<input type="password" name="password" class="form-control" id="yourPassword" required>
118
93
<div class="invalid-feedback">Please enter your password!</div>
119
94
</div>
95
+
120
96
<div class="col-6 d-flex">
121
97
<button class="btn btn-outline-primary w-100" type="submit" name="submit" value="submit">Login</button>
122
- </div>
98
+ </div>
123
99
</form>
124
100
</div>
125
-
126
-
127
101
</div>
102
+
128
103
</div>
129
104
</div>
130
105
</div>
131
106
</div>
132
-
133
107
</section>
134
-
135
- </div>
136
- </main><!-- End #main -->
137
-
138
- <a href="#" class="back-to-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>
108
+ </main>
139
109
140
110
<!-- Vendor JS Files -->
141
- <script src="assets/vendor/apexcharts/apexcharts.min.js"></script>
142
111
<script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
143
- <script src="assets/vendor/chart.js/chart.umd.js"></script>
144
- <script src="assets/vendor/echarts/echarts.min.js"></script>
145
- <script src="assets/vendor/quill/quill.js"></script>
146
- <script src="assets/vendor/simple-datatables/simple-datatables.js"></script>
147
- <script src="assets/vendor/tinymce/tinymce.min.js"></script>
148
- <script src="assets/vendor/php-email-form/validate.js"></script>
149
- <!-- Template Main JS File -->
150
- <script src="assets/js/main.js"></script>
151
112
152
113
<!-- ALERTIFY JavaScript -->
153
114
<script src="//cdn.jsdelivr.net/npm/alertifyjs@1.14.0/build/alertify.min.js"></script>
154
115
116
+ <!-- Display Alertify Pop-up at the Top of the Page -->
117
+ <?php if (!empty ($ error_message )): ?>
118
+ <script>
119
+ // Set Alertify to display notifications at the top of the page
120
+ alertify.set('notifier','position', 'top-center');
121
+ alertify.error("<?= $ error_message ?> ");
122
+ </script>
123
+ <?php endif ; ?>
124
+
155
125
</body>
156
126
157
- </html>
127
+ </html>
0 commit comments