$_POST
Last updated
What is $_POST?
$_POST is a superglobal variable in PHP that's used to collect form data submitted via HTTP POST method. Your PHP script can access this data through $_POST. Let's say you have a simple HTML form on your webpage. When the user submits this form, the entered data can be fetched using $_POST. Here's a brief example:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST["name"];
}
?>
In this code, $_POST["name"] fetches the value entered in the 'name' field of the form. Always be cautious when using $_POST as it may contain user input which is a common source of vulnerabilities. Always validate and sanitize data from $_POST before using it.
Free resources to learn $_POST
- Official docs$_POST
More in stage 8: Form Processing
$_POST: common questions
Can I learn $_POST in Hindi?
This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain $_POST in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.
Is this $_POST tutorial for beginners?
It is lesson 47 of 120 in the free PHP roadmap, in stage 8, Form Processing. If you are new to PHP, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.