What is the difference between using $_GET and $_POST to retrieve form data in PHP?

When retrieving form data in PHP, the main difference between using $_GET and $_POST is in how the data is sent. $_GET sends data through the URL, which can be seen in the browser's address bar and has a limit on the amount of data that can be sent. On the other hand, $_POST sends data through the HTTP request body, which is not visible in the URL and can handle larger amounts of data securely.

// Example of retrieving form data using $_POST
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $username = $_POST["username"];
    $password = $_POST["password"];
    
    // Process the form data
}