$username, 'password' => $password ); // Read the existing JSON data from the file $jsonData = file_get_contents($file); // Convert the JSON data to an array $existingData = json_decode($jsonData, true); // Add the new data to the existing array $existingData[] = $data; // Convert the array to JSON format $json = json_encode($existingData); // Save the JSON data to the file file_put_contents($file, $json); // Display a success message echo 'Username and password saved successfully!'; } // Read the JSON data from the file $jsonData = file_get_contents($file); // Convert the JSON data to an array $dataArray = json_decode($jsonData, true); ?>