<?php
include 'data.php';

$conn = new mysqli($host, $user, $pass, $db);

if ($conn->connect_error) {
    echo 'qqqqq';
    die("Koneksi Gagal: " . $conn->connect_error);
}

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


$result = mysqli_query($conn, "SELECT * FROM users WHERE username = '$username' AND password = '$password'");   
while($row = mysqli_fetch_assoc($result))
    $test[] = $row; 



// Periksa apakah ada baris di tabel user dengan username dan password yang diberikan
$query = "SELECT * FROM users WHERE username = '$username' AND password = '$password'";
$result = $conn->query($query);

if ($result->num_rows > 0) {
    // Jika ada baris yang sesuai, kirim respons sukses
    echo json_encode(['success' => true, 'message' => 'Login berhasil', 'qq' => $test ]);
} else {
    // Jika tidak ada baris yang sesuai, kirim respons gagal
    echo json_encode(['success' => false, 'message' => 'Username atau password salah']);
}

$conn->close();
?>

<?php
