<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
include('includes/config.php');
date_default_timezone_set('Asia/Kolkata');
if (isset($_POST['type']) && isset($_POST['member_id'])) {
    $type = $_POST['type'];
    $member_id = $_POST['member_id'];
    $in_time = date('Y-m-d H:i:s'); // current timestamp

    $sql = "INSERT INTO inout_records (type, member_id, in_time) VALUES (:type, :member_id, :in_time)";
    $query = $dbh->prepare($sql);
    $query->bindParam(':type', $type, PDO::PARAM_STR);
    $query->bindParam(':member_id', $member_id, PDO::PARAM_INT);
    $query->bindParam(':in_time', $in_time, PDO::PARAM_STR);

    if ($query->execute()) {
        $_SESSION['msg'] = "In record added successfully";
    } else {
        $_SESSION['error'] = "Failed to add record";
    }
}
