<?php
require 'admin-login.php';

$old = $_POST['old'];
$new = $_POST['new'];
$confirm = $_POST['confirm'];

$query = mysqli_query($link, "SELECT * FROM admin");

$row = mysqli_fetch_array($query);

if($old !== $row['password']){
    $_SESSION['alert'] = "Old Password Is Incorrect";
    header("Location: adminchangepassword.php");
}else{
    if($new !== $confirm){
        $_SESSION['alert'] = "Passwords Do Not Match!";
    header("Location: adminchangepassword.php");
    }else{
        $update = mysqli_query($link, "UPDATE admin SET password = '$new' ");
        $_SESSION['alert'] = "Password Has Been Successfully Changed";
    header("Location: adminchangepassword.php");
    }
}


?>