POST Array in PHP

The $_POST Array in PHP
<!--Write Here-->

Before learning this array you might want to learn the HTTP GET and POST methods in the HTML section of this website.

The form fields or any parameter passed to a PHP page with POST method can be retrieved in the PHP page using the inbuilt array $_POST[]. You can retrieve the array values using by using the names of the parameters.Hence $_POST Arrays are also associative in nature.

The following is the syntax of a get array.

$user = $_POST["userid"];

An example has been given in the next section which displays a webform with two fields. The form is submitted to the same page. The script displays the parameters submitted using the POST method. A form is submitted using the POST method when the "method" attribute of the form is set to POST or this attribute has not been set at all.

<!--Comment of this block-->

Example of Form processing using the $_POST[ ] Array
<!--Write Here-->
Save this file as post_array.php.

<html>
<head>
<title>$_POST Array</title>
</head>
<body>
<?php
    echo "User Id is:".$_POST["user"];
    echo "<br>Password is:".$_POST["password"];
?>
<form action=post_array.php method=POST>
UserId: 
<input type=text name=user>
Password:
<input type=text name=password>
<input type=submit value=Submit>
</form>
</body>
</html>