<?php
session_start();

$host = 'localhost';
$user = 'ahmeuesz_dino';
$pwd  = 'X39IW2ho3^5h6d_5';
$db   = 'ahmeuesz_myapp';
$conn = mysqli_connect($host, $user, $pwd, $db);

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $date = $_POST['date'];
    $fajar = $_POST['fajar'];
    $zuhar = $_POST['zuhar'];
    $asar = $_POST['asar'];
    $mghrib = $_POST['mghrib'];
    $esha = $_POST['esha'];
    $name = $_SESSION['name'];

    $sql = "INSERT INTO namaz_table (name, date, fajar, zuhar, asar, mghrib, esha) VALUES ('$name', '$date', '$fajar', '$zuhar', '$asar', '$mghrib', '$esha')";
    $result = mysqli_query($conn, $sql);

    if ($result) {
        // Redirect to display.php with success message (using GET)
        header('Location: display.php?msg=success');
        exit();
    } else {
        // Redirect to display.php with error message
        header('Location: display.php?msg=error');
        exit();
    }
}
?>
