Tips For Form Handling

Marc0

Well-known member
Registered
Joined
Jun 6, 2012
Messages
890
Points
28
Any time you need to gather information from the users of your Web sites, you'll need to use a form.

Forms can contain most of the usual graphical interface elements, including entry fields, radio buttons, check boxes, pop-up menus, and entry lists. In addition, HTML forms can contain password fields, shielding the user's input from prying eyes.

Once the form is filled out, a click on the form's Submit button sends the form's information to your Web server, where a CGI (that stands for Common Gateway Interface, and it's a script that runs on the Web server) interprets the data and acts on it. Often, the data is then stored in a database for later use. It's useful to make sure that the data the user enters is "clean," that is, accurate and in the correct format, before it gets stored on the server side. JavaScript is the perfect way to check the data; this is called form validation. Though the CGI can do the validation (and should as a backup measure, since some people will have JavaScript turned off in their browsers), it's much faster and more efficient for your users to also do it on the client's machine with JavaScript.

You'll learn how to use JavaScript to make sure that your forms contain valid information, check data in one field against the data in another field, and highlight incorrect information to let the user know what needs to be changed.

action
The name of the server-side CGI that is run when control is passed back to the Web server

input
A form field of varying types, depending on the value of the type attribute

class
The class assigned to the element

id
The unique id assigned to the element

name
Primarily used to group sets of radio buttons; also is a name that JavaScript can use to refer to this field; as with other JavaScript objects, no spaces or other punctuation is allowed, and it cannot start with a number

maxlength
The maximum length entry that the user may enter in this field

size
The number of characters that are displayed on the page

type
The type of input required; possible values are button, check box, image, password, radio, reset, submit, and text

value
The preset value of this form field

label
Used to specify labels for controls that do not have built-in labels, such as text fields, check boxes, radio buttons, and menus

for
Associates the label with a specific element's id

option
The possible options available inside a select tag

selected
Indicates whether this option is selected as the default

value
The preset value of each option

select
A form field that is either a pop-up menu or scrolling list, based on the size attribute

class
The class assigned to the element

id
The unique id assigned to the element

size
The number of options that are displayed on the page; if the attribute is set to 1, or this attribute is not present, the result is a pop-up menu
 

carvermediagroup

New member
Registered
Joined
Dec 15, 2012
Messages
7
Points
0
If your PHP program is a dynamic web page (and it probably is) and your PHP program is dealing with user input (and it probably is), then you need to work with HTML forms. Here are some tips for simplifying, securing, and organizing your form-handling PHP code.
 
Older Threads
Replies
1
Views
2,473
Replies
30
Views
11,133
Replies
20
Views
11,710
Replies
1
Views
3,273
Replies
6
Views
4,401
Newer Threads
Replies
0
Views
2,537
Replies
0
Views
2,277
Replies
0
Views
2,326
Replies
1
Views
2,440
Replies
3
Views
3,754
Latest Threads
Replies
0
Views
123
Replies
1
Views
79
Recommended Threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top