/* Decoded by unphp.net */ include('config.php'); $serverName = $IP; $connectionOptions = array( "Database"=>"RF_User", "Uid"=>$ID, "PWD"=>$PW ); $conn = sqlsrv_connect($serverName,$connectionOptions); if (!$conn) { die("Koneksi ke SQL Server gagal: ".print_r(sqlsrv_errors(),true)); } if (isset($_COOKIE['id'])) { $userId = $_COOKIE['id']; }elseif (isset($_SESSION['id'])) { $userId = $_SESSION['id']; }else { $userId = null; } if ($userId !== null) { $emailQuery = "SELECT email FROM tbl_RFTestAccount WHERE Id = CONVERT(binary(16), ?)"; $emailParams = array($userId); $emailStmt = sqlsrv_query($conn,$emailQuery,$emailParams); if ($emailStmt === false) { die("Error: ".print_r(sqlsrv_errors(),true)); } $row = sqlsrv_fetch_array($emailStmt,SQLSRV_FETCH_ASSOC); if ($row === false) { die("ID pengguna tidak ditemukan."); } $storedEmail = $row['email']; $confirmEmail = $_POST['confirmEmail']; if ($confirmEmail !== $storedEmail) { $response = array( "status"=>"error", "message"=>"Email tidak cocok." ); }else { $newPassword = $_POST['newPassword']; $updateQuery = "UPDATE tbl_RFTestAccount SET password = CONVERT(binary(24), ?) WHERE Id = CONVERT(binary(16), ?)"; $updateParams = array($newPassword,$userId); $updateStmt = sqlsrv_query($conn,$updateQuery,$updateParams); if ($updateStmt === false) { $response = array( "status"=>"error", "message"=>"Error: ".print_r(sqlsrv_errors(),true) ); }else { $response = array( "status"=>"success", "message"=>"Password berhasil diubah." ); } } } header('Content-Type: application/json'); echo json_encode($response); sqlsrv_close($conn); ;