PHP FORMS
Setting up a form for use with a PHP script is exactly the same as normal in HTML. Most forms are used to gather information like in a signup form, survey or guestbook.
The most important thing to notice when dealing with HTML forms and PHP is that any form element in an HTML page will automatically be available to your PHP scripts.
All the elements for your form must be enclosed in the
Note : It really makes no difference if you use POST or GET as method but it is normally better to use POST if you are using passwords or sensitive information as they should not be shown in the browser's address bar.
We used the following line to define the action file (process.php) and action method (post)
<form action="process.php" method="post">
After submitting the form the next step is to get the data the form has submitted into your script so that you can do something with it.
To get a variable which has been sent to a script using the POST method you use the following code:
$variablename=$_POST['variable'];
which basically takes the variable from the POST (the name of a form field) and assigns it to the variable $variablename.
Similarly, if you are using the GET method you should use the form:
$variablename=$_GET['variable'];
This should be done for each variable you wish to use from your form (or URL).