-
Notifications
You must be signed in to change notification settings - Fork 0
/
login-old.php
153 lines (124 loc) · 3.31 KB
/
login-old.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
<?php
// login_process.php
// Enable error reporting for this script
ini_set('display_errors', 1);
error_reporting(E_ALL);
// Custom error handler function
function customErrorHandler($errno, $errstr, $errfile, $errline) {
echo "<div style='color: red; border: 1px solid red; padding: 10px; margin: 10px;'>";
echo "<strong>Error:</strong> [$errno] $errstr<br>";
echo "Error on line $errline in file $errfile<br>";
echo "</div>";
}
// Set custom error handler
set_error_handler("customErrorHandler");
// Start or resume the session
session_start();
// If the user is already logged in, redirect to the dashboard
if (isset($_SESSION['username'])) {
header("Location: public/dashboard.php"); // Adjust the path based on your actual dashboard page location
exit();
}
// Include the header
include 'public/header.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.maincontainer {
font-family: "Comic Sans MS", cursive;
margin: 0;
display: flex;
align-items: center;
justify-content: center;
min-height: 15vh;
}
.container {
margin-top: 2%;
width: 100%;
max-width: 380px;
margin-top:20px;
margin-right:40px;
}
.card {
width: 100%;
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
h2 {
text-align: center;
color: #333;
}
form {
display: flex;
flex-direction: column;
}
input {
padding: 10px;
margin-bottom: 12px;
border: 1px solid #ddd;
border-radius: 4px;
transition: border-color 0.3s ease-in-out;
outline: none;
color: #333;
}
input:focus {
border-color: #ff4500;
}
button {
background-color: #ff4500;
color: #fff;
padding: 10px;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease-in-out;
}
button:hover {
background-color: #e63900;
}
</style>
</head>
<body>
<div class="maincontainer">
<div class="container">
<div class="card">
<h2>Namaste!</h2>
<form action="config/login_process.php" method="post">
<input type="text" id="username" name="username" placeholder="Username" required>
<input type="password" id="password" name="password" placeholder="Password" required>
<button type="submit">Login</button>
</form>
<br>
<!-- Display error messages here -->
<?php
if (isset($_GET['error'])) {
$error = $_GET['error'];
if ($error === 'invalid_login') {
echo '<p style="color: red;text-align: center;">Incorrect username or password.</p>';
} elseif ($error === 'user_not_found') {
echo '<p style="color: red;text-align: center;">User not found.</p>';
}
// Redirect to login.php after 5 seconds
echo '<meta http-equiv="refresh" content="5;url=login.php" />';
}
?>
</div>
</div></div>
<script>
// You can keep your existing JavaScript for other purposes, if any
function validateForm() {
// Add any client-side validation if needed
return true; // Allow form submission
}
</script>
</body>
<?php
// Include the footer
include 'public/footer.php';
?>