0% found this document useful (0 votes)
28 views

PHP Tizag Tutorial-50

This document discusses the POST and GET methods for submitting HTML form data to a PHP page for processing. The POST method stores form values in the $_POST associative array using the form element names as keys. The PHP code then accesses these values using the same keys. The GET method similarly stores values in the $_GET array. Forms should not have duplicate element names to avoid problems accessing values.

Uploaded by

Anil Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

PHP Tizag Tutorial-50

This document discusses the POST and GET methods for submitting HTML form data to a PHP page for processing. The POST method stores form values in the $_POST associative array using the form element names as keys. The PHP code then accesses these values using the same keys. The GET method similarly stores values in the $_GET array. Forms should not have duplicate element names to avoid problems accessing values.

Uploaded by

Anil Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

PHP - POST & GET

Recall from the PHP Forms Lesson where we used an HTML form and sent it to a PHP web page for
processing. In that lesson we opted to use the the post method for submitting, but we could have also chosen
the get method. This lesson will review both transferring methods.

POST - Review

In our PHP Forms Lesson we used the post method. This is what the pertinent line of HTML code looked
like:

HTML Code Excerpt:


<form action="process.php" method="post">
<select name="item">
...
<input name="quantity" type="text" />

This HTML code specifies that the form data will be submitted to the "process.php" web page using the
POST method. The way that PHP does this is to store all the "posted" values into an associative array called
"$_POST". Be sure to take notice the names of the form data names, as they represent the keys in the
"$_POST" associative array.
Now that you know about associative arrays, the PHP code from "process.php" should make a litte more
sense.

PHP Code Excerpt:


$quantity = $_POST['quantity'];
$item = $_POST['item'];

The form names are used as the keys in the associative array, so be sure that you never have two input
items in your HTML form that have the same name. If you do, then you might see some problems arise.

You might also like