This repository was archived by the owner on Jun 28, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathindex.php
More file actions
118 lines (105 loc) · 3.76 KB
/
Copy pathindex.php
File metadata and controls
118 lines (105 loc) · 3.76 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
<?php
include 'config.php';
if (isset($_SESSION['uid'])) {
if($_SESSION['role'] == 'admin') {
header("Location: dashboard_admin.php");
} else {
header("Location: dashboard_user.php");
}
exit();
}
if (isset($_POST['login'])) {
$nohp = mysqli_real_escape_string($conn, $_POST['nohp']);
$pass = $_POST['password'];
$q = mysqli_query($conn, "SELECT * FROM users WHERE nohp='$nohp' AND password='$pass'");
if(mysqli_num_rows($q) > 0){
$d = mysqli_fetch_assoc($q);
$_SESSION['uid'] = $d['id'];
$_SESSION['role'] = $d['role'];
$_SESSION['nama'] = $d['nama'];
if (isset($_SESSION['redirect_after_login'])) {
$url = $_SESSION['redirect_after_login'];
unset($_SESSION['redirect_after_login']);
header("Location: " . $url);
} else {
if($d['role'] == 'admin') header("Location: dashboard_admin.php");
else header("Location: dashboard_user.php");
}
exit();
} else {
$error = "Invalid phone number or password!";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login - Event Attendance</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
<style>
body {
background: #f0f2f5;
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
.login-card {
width: 100%;
max-width: 400px;
border-radius: 15px;
border: none;
}
.login-header {
text-align: center;
margin-bottom: 20px;
}
.btn-login {
background-color: #0d6efd;
border: none;
padding: 12px;
font-size: 16px;
font-weight: bold;
}
.btn-login:hover {
background-color: #0b5ed7;
}
</style>
</head>
<body>
<div class="container p-3">
<div class="card shadow login-card mx-auto p-4">
<div class="card-body">
<div class="login-header">
<h3 class="fw-bold text-primary">Event Attendance</h3>
<p class="text-muted">Please login with your phone number</p>
</div>
<?php if(isset($error)): ?>
<div class="alert alert-danger text-center p-2 mb-3">
<small><?= $error ?></small>
</div>
<?php endif; ?>
<form method="POST">
<div class="mb-3">
<label class="form-label fw-bold small">Phone Number</label>
<input type="number" name="nohp" class="form-control form-control-lg" placeholder="e.g. 0812..." required autofocus>
</div>
<div class="mb-4">
<label class="form-label fw-bold small">Password</label>
<input type="password" name="password" class="form-control form-control-lg" placeholder="Enter password" required>
</div>
<div class="d-grid">
<button type="submit" name="login" class="btn btn-primary btn-login text-white">LOGIN</button>
</div>
</form>
<div class="text-center mt-4">
<p class="small text-muted mb-1">Not registered yet?</p>
<a href="register.php" class="fw-bold text-decoration-none">Create New Account</a>
</div>
</div>
</div>
</div>
</body>
</html>