<?php
header("Content-Type: application/json");

$host = 'localhost';
$user = 'ahmeuesz_dino';
$pwd  = 'X39IW2ho3^5h6d_5';
$db   = 'ahmeuesz_myapp';

$conn = mysqli_connect($host, $user, $pwd, $db);

$email = $_POST['email'];
$password = $_POST['password'];

$sql = "SELECT * FROM users WHERE email='$email' AND password='$password'";
$res = mysqli_query($conn, $sql);

if (mysqli_num_rows($res) > 0) {
    $user = mysqli_fetch_assoc($res);

    echo json_encode([
        "status" => "success",
        "message" => "Login Successful",
        "user" => $user
    ]);

} else {
    echo json_encode([
        "status" => "failed",
        "message" => "Login failed"
    ]);
}
?>
