// Sample script to handle authentication // Define the correct username and password $correct_username = 'Troy'; $correct_password = 'Wand'; // Check if the request method is POST if ($_SERVER['REQUEST_METHOD'] === 'POST') { // Check if both username and password are provided in POST data if (isset($_POST['username']) && isset($_POST['password'])) { // Retrieve username and password from POST data $username = $_POST['username']; $password = $_POST['password']; // Check if the provided credentials match the correct username and password if ($username === $correct_username && $password === $correct_password) { // Authentication successful $response = array( 'success' => true, 'message' => 'Login successful', // You may include additional data like user roles or session tokens here ); } else { // Authentication failed $response = array( 'success' => false, 'message' => 'Invalid username or password', ); } } else { // Username or password not provided $response = array( 'success' => false, 'message' => 'Username and password are required', ); } } else { // Handle if the request method is not POST $response = array( 'success' => false, 'message' => 'Invalid request method', ); } // Send the JSON response header('Content-Type: application/json'); echo json_encode($response); ?>