PHP Form Handling
PHP Form Handling
Form
• A Document that containing blank fields, that
the user can fill the data or user can select the
data.
• It is like interface to send data to web server
• There are two ways the browser client can
send information to the web server.
The GET Method
The POST Method
GET and POST
• Both GET and POST create an array
e.g. array( key1 => value1, key2 => value2,
key3 => value3, ...)
• This array holds key/value pairs, where keys
are the names of the form controls and values
are the input data from the user.
• The respective arrays are
$_GET and $_POST (built in arrays)
The GET Method
• Information sent from a form with the GET
method is visible to everyone (all variable
names and values are displayed in the URL).
• GET also has limits on the amount of
information to send. The limitation is about
2000 characters.
• GET may be used for sending non-sensitive data.
• Note: GET should NEVER be used for sending
passwords or other sensitive information!
The POST Method
</body>
</html>
PHP code (welcome.php)
<html>
<body>
<?php
$a=$_POST['name'];
$b=$_POST[‘age'];
echo "Welcome ".$a"<br />";
echo "You are ". $b. " years old.";
?>
</body>
</html>