<?php
session_start();
$con = mysqli_connect("localhost", "root", "", "WSAS");

if (!$con) {
    die("Connection failed: " . mysqli_connect_error());
}

$email = mysqli_real_escape_string($con, $_POST['email']);
$password = $_POST['password'];

$query = mysqli_query($con, "SELECT * FROM admin_login WHERE email='$email'");

if (!$query) {
    die("Query failed: " . mysqli_error($con));
}

$user = mysqli_fetch_assoc($query);

if ($user && $password === $user['passwrod']) {
    $_SESSION['login_id'] = $user['login_id'];
    header("Location: ../adminpanel/admindashboard.php");
    exit();
} else {
    echo "<script>alert('Invalid email or password'); window.location.href='login.php';</script>";
}
?>