$_POST in PHP. Code example open

$_POST in PHP. Code example

Approved. Code works!
This is exactly the working code that is verified by the moderator or site administrators
Tested: PHP 5.6 +

The POST method transmits information through HTTP headers. The information is encoded as described for the GET method and placed in the QUERY_STRING header.

!The POST method has no limits on the amount of data sent.
!Data sent using the POST method passes through an HTTP header, so its security depends on the HTTP protocol. By using Secure HTTP, you can keep your information secure.

We can access these elements as if they were elements of a normal array.
echo $_POST['login'];

Example of use:

Let’s create the usual html form:

<form action = "test.php" method = "POST">
        <input type = "text" name = "name" placeholder = "Name" />
        <input type = "text" name = "surname" placeholder = "Surname" />
        <input type = "submit" />
     </form>

When you click the submit button, our form will send the data to the test.php page.
On the test.php transfer page, the data will be contained in a variable $_POST or $_REQUEST
We can now use our form data by accessing the array:

 

$name = $_POST["name"];
$surname = $_POST["surname"];

 

PHP variable $_REQUEST contains content as $_GET, $_POST

$_GET in PHP. Code example open
$_GET in PHP. Code example
May 4, 2022
Roman-tk
0

More

Leave a Reply

Your email address will not be published. Required fields are marked *

How many?: 22 + 22

lil-code© | 2022 - 2024
Go Top
Authorization
*
*
Registration
*
*
*
*
Password generation