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

    // Update the renter table
    $sql = "UPDATE renter SET Renter_Pass = '$Pass', Renter_Name = '$Name', Renter_PhoneNum = '$PhoneNum', Renter_Age = '$Age', Renter_Email = '$Email' WHERE Renter_ID = '$AccID'";

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

    if ($result) {
        echo "<script>alert('Data Had Been Saved')</script>";
        echo "<script>window.location = 'renterProfile.php'</script>";
        exit();
    } else {
        echo "<script>alert('Renter ID is already exist or error type entering')</script>";
        echo "<script>window.location = 'renterProfile.php'</script>";
        exit();
    }
    
    mysqli_close($conn); // Close connection
}
?>
