Make your own free website on

Visit the Official PHP Website

Search this Site

PHP Programming

By James N Hitz

Your Forms are Ok?

It is very common-place to make sloppy or in-complete HTML. Common browsers in the market are too smart and they don't mind. They always fix the probem somehow. Take a look at this:

	<input type = "text">

This will give you a textbox all right. But you cannot use this textbox with PHP. This is because PHP expects that you at least have a name attribute for each HTML form widget. Remember?

To make the above text box "PHP-usable", we will therefore code:

	<input type ="text" name= "name_here">

And there's more... Some form widgets eg. radio buttons and check boxes that present the same subject MUST share the same name. Let's create an example in which the user supply their marital status:

<p>Marital Status:
	<input type="radio" name ="Mstatus"> Single
	<input type="radio" name= "Mstatus"> Married
	<input type="radio" name= "Mstatus"> Widow(ered)
	<input type = "submit">

That is not all! There are still some more form considerations...

See the PHP script executed will not "know" which of the marital statuses was chosen from the three. None has a value!

Therefore, apart from assigining a name to each and every form widget, you should also make sure at least the following widgets:...

  1. radio buttons
  2. check boxes
  3. images
  4. hidden controls
  5. options (within <SELECT>)
  6. buttons (button, submit and reset)

...have a value attribute assigned to each of them.

Revisiting the above buttons on the marital issue:

<p>Marital Status:<br>
<br><INPUT type="radio" name ="Mstatus" value="Single"> Single
<br><INPUT type="radio" name= "Mstatus" value="Married"> Married
<br><INPUT type="radio" name= "Mstatus" value="Widow"> Widow(ered)

Remember PHP is CASE SeNsiTivE and the names will be used in PHP. If they represent the same issue (as these ones represent the marital status), then they must have the same form of CaPiTaLiZation for the name.

Ok. So what happens next?

<< About this Lesson | Form's action >>

JamHitz Productions