Search⌘ K
AI Features

Submitting Data via the Request Body: POST Requests

Explore how to submit form data through the request body using POST in PHP. Learn why POST requests improve security by keeping sensitive data out of URLs and how to access submitted data differently from GET requests.

Why submit data through the request body?

Submitting form data using query parameters is nice and easy, but it should only be used for really simple forms that only have short-term effects. Most forms are used to collect information from the user, which is then going to be saved to a database. Some forms have sensitive or personal data that should not visibly end up in the URL. Imagine a username and a password being submitted as query parameters: /register username=coolguy1984&password=ilovecookies. This URL ends up in the browser’s history. The username and password will also show up in server log ...