<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Content-Type");
header("Access-Control-Allow-Methods: POST");

$host = "localhost";
$user = "wanywebc_baski";
$pass = "Adgebs123.";
$db   = "wanywebc_baski";

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

if ($conn->connect_error) {
    echo json_encode(["success" => false, "message" => "Veritabanı bağlantı hatası"]);
    exit;
}

$data = json_decode(file_get_contents("php://input"), true);
$email = $conn->real_escape_string($data["email"]);
$password = $conn->real_escape_string($data["password"]);

$sql = "SELECT * FROM kullanicilar WHERE email = '$email' AND sifre = '$password'";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    echo json_encode(["success" => true, "message" => "Giriş başarılı"]);
} else {
    echo json_encode(["success" => false, "message" => "E-posta veya şifre yanlış"]);
}

$conn->close();
?>
