Module #8 blog post

Title: GETvs_POST 

$_GET: data in the URL query string (method=”get”). Visible/bookmarkable, but only up to a certain length of URL.

$_POST: information in the request body (method=”post”). Not in the URL; supports larger payloads and file uploads (enctype=”multipart/form-data”).

In short, some important differences are

GET shows the URL and history, but POST hides them.

Size: The length of the URL limits GET. This is fine for short things like a search query (for example, ?q=coffee), but not for big JSON payloads or file uploads. POST, by contrast, lets you send much more data (think a CSV or photo upload), though you’re still constrained by server settings like post_max_size and upload_max_filesize.

Semantics: GET is best for safe, read‑only requests you might bookmark or share; POST should be used for actions that change state — creating, updating, or deleting resources. A quick caveat: POST isn’t magically secure — use HTTPS and validate on the server.

Bookmarking and caching: GET can be bookmarked or cached, but POST can’t.

Only POST can be used to upload.

examples

GET form: $_GET[‘q’]

POST form: $_POST[’email’]

Best ways to do things: Use GET for searches, filters, and requests that can be saved as bookmarks. Use POST for actions that are private or change the state of something, and uploads. Use HTTPS and always check and clean up on the server.

Leave a comment