<?php
/* include db connection file */
include("connection.php");
session_start();
if(isset($_POST['submit'])){
    /* capture values from HTML form */
    $ID = $_POST['ID'];
    $Pass = $_POST['Pass'];
    $Name = $_POST['Name'];
    $PhoneNum = $_POST['PhoneNum'];
    
    $AccID = $_SESSION['AccAdminID'];

    // Update the renter table
    $sql = "UPDATE admin SET Admin_ID = '$ID', Admin_Pass = '$Pass', Admin_Name = '$Name', Admin_PhoneNum = '$PhoneNum' WHERE Admin_ID = '$AccID'";

    $result = mysqli_query($conn, $sql);

    if ($result) {
        echo "<script>alert('Updated is successfull')</script>";
        $_SESSION['AccID'] = $ID;
        echo "<script>window.location = 'adminProfile.php'</script>";
        exit();
    } else {
        echo "<script>alert('ID is already exist')</script>";
        echo "<script>window.location = 'adminProfile.php'</script>";
    }
    
}
?>
