Make your own free website on Tripod.com

Visit the Official PHP Website

Search this Site

PHP Programming

By James N Hitz

The form's action and method attributes

  1. So you have proper HTML forms? Check!
  2. Each widget has a name? Check!
  3. Each widget has a value where applicable? Check!
  4. So... What else?

The entire form will be required to have an action properly (attribute) set. This one specifies the name of the PHP script that will be run by the server when you <SUBMIT> the form.

The form will also also have a method property set to either GET or POST. This determines HOW the data supplied on the HTML form is actually sent to the user. For small forms METHOD=GET is ok but METHOD=POST is more ideal for large forms especially if they happen to have a <textarea> form widget. In all cases here-in the method will be set to POST

Let's take an example of a HTML form:

<form action="/php-bin/person.php" METHOD=POST>
	Your Name:
	   <input type="text" name= "username">
	Your email address:
	   <input="text" name= "username">
	Marital status:
	   <input type="radio" name="Mstatus" Value "single"> Single
	   <input type="radio" name="Mstatus" value="Married"> Married
	   <input type="radio" name "Mstatus" value="Widow"> Widow(ered)
	   <input type="submit" value=" Ok ">
</form>

Preach water drink wine! How come I said give a name to each and every form widget and yet I haven't given a name to my <SUBMIT> button?

Well forget my... hic! ... Well you see... hic! ... hic!

In this case my SUBMIT button will send the form data to the server but thats it! I cannot refer to it in my PHP script. As far as my PHP script is concerned, it will be non-existent.

How about the others? {panic} Not to worry. We will be able to use them in our PHP scripts because they all have names and values (which the user will HOPEFULLY) enter.{/panic}

Question is: How will we use the form data?

<< Form Setup | The Form Data >>

JamHitz Productions