Loading

$_POST Super Global Variable

$_POST — HTTP $_POST variables is a global variable and it is available throughout the script which means there is no need to declare a global variable to access this. It collects data from the form after submitting, For this form use the POST method. POST method passes the value in the form of an associative array. and POST sends data using the HTTP POST method on the server as the content type in the request. This method $_POST is available after the stable release of PHP 4 and above.

When passing the form data using the POST method It will be invisible to others. and also no limit to the amount of information to send.

Bookmarking of pages is not possible because the information will not pass through the URL.

Both Binary, as well as ASCII data, can be sent off with the POST method.

The Post Method transfers the information via the Headers.

POST method is a secure method, we can use it like a login form or any other sensitive data form.

POST method is slow.

If we want to receive application/json post data in your script you can not use $_POST. $_POST does only handle form data. $_POST is NOT set for all HTTP POST operations,  but only for specific types of POST operations.

For Example:-

<form method=”post” action=”<?php $_SERVER[”PHP_SELF’];?>”>

Your Name: <input type=”text” name=”name”>

<input type=”submit” value=”GO”>

</form>

<?php

if ($_SERVER[“REQUEST_METHOD”] == “POST”) {

// collect value of input field

$name = $_POST[‘name’];

if (empty($name)) {

echo “Name is empty”;

} else {

echo $name;

}

}

?>

Leave a Reply

z35W7z4v9z8w
Verified by ExactMetrics