PHP Programing language

Previous Home Next

In PHP forms lesson we use HTML form and sent it to a PHP web page for processing. Then this form we opted to use in the post method for submitting, but we can chose the get method.

PHP Post

In the PHP Forms Lesson we used the post method.


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

This HTML code is specifies that the form data will be submitted to the "pro.php" this web page using the POST method. this web page 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.

In associative arrays, the PHP code from "pro.php" should make a little more sense. In associative arrays, the PHP code from "pro.php" should make a little more sense.

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

Note: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.

The PHP Get

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

The get method is different in that it passes the variables along to the "pro.php" web page by appending them onto the end of the URL. The URL, after clicking submit, would have this added on to the end of it.

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

After changing the array name the script will function properly. then use the get method and displaying the variable information to your visitor, so be sure you are not sending password information or other sensitive items with the get method. You would not want your visitors seeing something they are not supposed to.

Previous Home Next