<?php
session_start();
include 'koneksi.php';

$user = trim($_POST['username']);
$pass = trim($_POST['password']);

$q = mysqli_query($conn,
    "SELECT * FROM admin WHERE username='$user' AND password='$pass'"
);

if (mysqli_num_rows($q) === 1) {
    $_SESSION['login'] = true;
    $_SESSION['username'] = $user;
    header("Location: dashboard.php");
    exit;
} else {
    header("Location: login.php?error=1");
    exit;
}
