Delete index.php
This commit is contained in:
parent
a2bfd38a33
commit
bf438cfbba
50
index.php
50
index.php
@ -1,50 +0,0 @@
|
|||||||
<?php
|
|
||||||
session_start();
|
|
||||||
require 'db.php';
|
|
||||||
|
|
||||||
|
|
||||||
$err = '';
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
||||||
$username = trim($_POST['username'] ?? '');
|
|
||||||
$password = $_POST['password'] ?? '';
|
|
||||||
|
|
||||||
|
|
||||||
if ($username === '' || $password === '') {
|
|
||||||
$err = 'Username dan password harus diisi.';
|
|
||||||
} else {
|
|
||||||
$stmt = $pdo->prepare('SELECT id, password FROM users WHERE username = ? LIMIT 1');
|
|
||||||
$stmt->execute([$username]);
|
|
||||||
$user = $stmt->fetch();
|
|
||||||
if ($user && password_verify($password, $user['password'])) {
|
|
||||||
session_regenerate_id(true);
|
|
||||||
$_SESSION['user_id'] = $user['id'];
|
|
||||||
$_SESSION['username'] = $username;
|
|
||||||
header('Location: menu.php');
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
$err = 'Username atau password salah.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="id">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
||||||
<title>Login - Dam Inggris</title>
|
|
||||||
<link rel="stylesheet" href="assets/css/style.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="auth-card">
|
|
||||||
<h1 style="text-align: center;">Login - Ke Main Menu</h1>
|
|
||||||
<?php if ($err): ?><div class="error"><?php echo htmlspecialchars($err); ?></div><?php endif; ?>
|
|
||||||
<form method="post" action="">
|
|
||||||
<label style="text-align: center;">Username<input name="username" required></label>
|
|
||||||
<label style="text-align: center;">Password<input type="password" name="password" required></label>
|
|
||||||
<button type="submit">Login</button>
|
|
||||||
</form>
|
|
||||||
<p style="text-align: center;">Belum punya akun? <a href="register.php">Daftar di sini</a></p>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Loading…
x
Reference in New Issue
Block a user