32 lines
944 B
PHP
32 lines
944 B
PHP
<?php
|
|
include 'koneksi.php';
|
|
header('Content-Type: application/json');
|
|
|
|
if (!isset($_POST['id_account']) || !isset($_POST['pin'])) {
|
|
echo json_encode(["status" => "error", "message" => "Data tidak lengkap"]);
|
|
exit;
|
|
}
|
|
|
|
$id = $_POST['id_account'];
|
|
$pin = $_POST['pin'];
|
|
|
|
try {
|
|
$stmt = $pdo->prepare("SELECT pin, password_enc FROM account WHERE id_account = ?");
|
|
$stmt->execute([$id]);
|
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if ($row) {
|
|
if ($row['pin'] === $pin) {
|
|
// Berikan password aslinya
|
|
echo json_encode(["status" => "success", "password" => $row['password_enc']]);
|
|
} else {
|
|
echo json_encode(["status" => "error", "message" => "PIN salah!"]);
|
|
}
|
|
} else {
|
|
echo json_encode(["status" => "error", "message" => "Akun tidak ditemukan"]);
|
|
}
|
|
} catch (Exception $e) {
|
|
echo json_encode(["status" => "error", "message" => $e->getMessage()]);
|
|
}
|
|
?>
|