<?php 
// Database connection
$conn = mysqli_connect("localhost", "aksoftwarecoimba_yugam", "9994613878@@", "aksoftwarecoimba_yugam");

if (!$conn) {
    echo json_encode([
        "status" => "error",
        "message" => "Database connection failed"
    ]);
    exit;
}

/* READ JSON DATA */
$data = json_decode(file_get_contents("php://input"), true);

if(!empty($data))
{
    foreach($data as $row)
    {

        $login_pk = $row['login_pk'];
        $code = $row['code'];
        $agent = $row['agent'];
        $password = $row['password'];
        $isadmin = $row['isadmin'];
        $login_status = $row['login_status'];
        $AutoIncrement = $row['AutoIncrement'];
        $branch_id = $row['branch_id'];
        $remit_user = $row['remit_user'];

        $sql = "INSERT INTO login
        (login_pk,code,agent,password,isadmin,login_status,AutoIncrement,branch_id,remit_user)
        VALUES
        ('$login_pk','$code','$agent','$password','$isadmin','$login_status','$AutoIncrement','$branch_id','$remit_user')";

        mysqli_query($conn,$sql);
    }

    echo json_encode(["status"=>"success","message"=>"Login data inserted"]);

}
else
{
    echo json_encode(["status"=>"error","message"=>"No data received"]);
}

?>