<?php
header('Content-Type: text/plain');
include 'config.php';

$missing = [];

if (!isset($_POST['Mobile_Number']) || trim($_POST['Mobile_Number']) === '') {
    $missing[] = 'Mobile_Number';
}
if (!isset($_POST['Password']) || trim($_POST['Password']) === '') {
    $missing[] = 'Password';
}
if (!isset($_POST['android_id']) || trim($_POST['android_id']) === '') {
    $missing[] = 'android_id';
}

if (!empty($missing)) {
    echo "All fields are required";
    exit;
}

$Mobile_Number = trim($_POST['Mobile_Number']);
$Password = trim($_POST['Password']);
$android_id = trim($_POST['android_id']);

$stmt = $conn->prepare("SELECT * FROM users WHERE Mobile_Number = ? AND Password = ? LIMIT 1");
$stmt->bind_param('ss', $Mobile_Number, $Password);
$stmt->execute();
$result = $stmt->get_result();

if ($result->num_rows == 0) {
    echo "User Not Found";
    exit;
}

$row = $result->fetch_assoc();

if ($row['android_id'] === $android_id) {
    echo "Login Successful";
} else {
    echo "Device Not Match";
}
?>