GET vs POST: which should my form use?

PHP & the Web 2 min read Full lesson: Building a PHP Web Form
Short answer

Use GET when the request only reads data and the URL should be shareable. Use POST when the request changes something, or carries anything you would not want in a browser history or server log.

GETPOST
Where the data goesThe URLThe request body
BookmarkableYesNo
Size limit~2000 charactersEffectively none
Safe to repeatYesNo
Read in PHP from$_GET$_POST

#Use GET for

Search boxes, filters, pagination, sorting. You want /search?q=python&page=2 to be shareable and bookmarkable.

#Use POST for

Logins, sign-ups, comments, purchases, deletions. Anything that changes server state.

#Detecting which you got

php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // handle the submission
}

Check the method, not isset($_POST['field']). An unchecked checkbox is not sent at all, so a field check can wrongly conclude nothing was submitted.

#Redirect after POST

php
if ($_SERVER['REQUEST_METHOD'] === 'POST' && !$errors) {
    header('Location: /thanks.php');
    exit;
}

Without this, refreshing the result page resubmits the form — which is how one message becomes five. The pattern is called Post/Redirect/Get.