Hudzilla.org - the homepage of Paul Hudson
Contents > HTML Forms > Designing a form Wish List | Report Bug | About Me ]

7.3.2     Available elements

This is NOT the latest copy of this book; click here for the latest version.

Now it is time to add in some form elements - there are quite a few to choose from. Here are a list of the most important ones for PHP usage:

Element

Description

INPUT TYPE="CHECKBOX"

A check box that lets users select multiple options

INPUT TYPE="FILE"

A text box plus a button that opens a file selection dialog

INPUT TYPE="HIDDEN"

A hidden form element where you set the value

INPUT TYPE="PASSWORD"

A text box where the text is replaced by a password character (usually asterisk *)

INPUT TYPE= "RADIO"

A radio button. Radio buttons are liked grouped check boxes - you can only select one at a time

INPUT TYPE="RESET"

A button to clear the form. It's one of the weird oddities of the web that this still exists - do you know anyone who uses it?

INPUT TYPE="SUBMIT"

A button to submit the form

INPUT TYPE="TEXT"

A text box

OPTION

An option in a SELECT element

SELECT

A list box; can also be a drop down list box

TEXTAREA

multi-line text box

There are four special elements in there that are of particular note: FILE elements actually upload files to the server, and can take quite a time to transfer if the connection speed is slow - handling file uploads is covered later. Hidden elements don't appear on your users screen - they are useful when keeping information across forms and pages, or simply just to force input for certain fields.

Password elements hide the password on the client side by using *s or something similar, but it is important to note that the password is still sent in plain text - no encryption is done. Finally, text area elements need a closing tag, with the text in between forming their content, i.e.: <TEXTAREA>Some text</TEXTAREA>.





<< 7.3.1 GET and POST   7.3.3 A working form >>
Table of Contents
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.



My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!



Top-right shadow
 
Bottom-left shadow Bottom shadow

Comments from other readers
A PHP User - 05 Sep 2008

fuck

A PHP User - 05 Sep 2008

The annoying thing about the reset button is when you accidently hit that instead of submit after filling in a long form.

A PHP User - 05 Sep 2008

I was astonished about the comment about the reset form button. It's actually very common and extremely useful in book catalogue websites e.g. Academic libraries. It's because academic library searches often entail quite complex searches which are only changed a little between each search, so you can return to your previous search without having to enter all the data again. And when you do want a completely new search you just reset the form with the reset form button.



Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.

If you are reporting an error in the content, please tell me directly.

Your name/email address:
Your comment:
 
Now, in order to verify that you're a real person, please answer this simple question: what is four plus two?
The answer is:
(please write in
numbers, eg 19)


Top-right shadow
 
Bottom-left shadow Bottom shadow