Upload files to "/"

This commit is contained in:
2026-06-05 03:09:29 +00:00
parent afcd403620
commit 0d1fe90613
5 changed files with 802 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
<?php
session_start();
include 'koneksi.php';
// Cek apakah form disubmit
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
header("Location: login.php");
exit;
}
// Ambil data dari form
$username = trim($_POST['username'] ?? '');
$password = trim($_POST['password'] ?? '');
// Validasi tidak boleh kosong
if (empty($username) || empty($password)) {
header("Location: login.php?error=empty");
exit;
}
// Cek ke database
$stmt = $conn->prepare("SELECT * FROM admin WHERE username = ?");
$stmt->bind_param("s", $username);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
$admin = $result->fetch_assoc();
// Cek password
if ($password === $admin['password']) {
$_SESSION['login'] = true;
$_SESSION['username'] = $username;
// Redirect ke admin.php
header("Location: admin.php");
exit;
}
}
// Login gagal
header("Location: login.php?error=wrong");
exit;
?>