Presentation is loading. Please wait.

Presentation is loading. Please wait.

Site Development Foundations © 2004 ProsoftTraining All rights reserved.

Similar presentations


Presentation on theme: "Site Development Foundations © 2004 ProsoftTraining All rights reserved."— Presentation transcript:

1 Site Development Foundations © 2004 ProsoftTraining All rights reserved

2 Lesson 7: Web Forms

3 Objectives Identify Web form elements for HTML and XHTML Identify Web form elements for HTML and XHTML Construct a Web form Construct a Web form Test Web forms using a public test engine Test Web forms using a public test engine

4 Introduction to Web Forms Forms are used to obtain information from users Forms are used to obtain information from users Input can include the user’s name, address or credit card number, for exampleInput can include the user’s name, address or credit card number, for example The information that a user submits in the form is sent to a server, where it is stored and/or processedThe information that a user submits in the form is sent to a server, where it is stored and/or processed Forms are essential for e-commerce, as well as for gathering information Forms are essential for e-commerce, as well as for gathering information

5 Web Forms and CGI To be truly functional, a form requires the use of a Common Gateway Interface (CGI) program to process and organize the user input To be truly functional, a form requires the use of a Common Gateway Interface (CGI) program to process and organize the user input A CGI script residing on a server performs two important functions: A CGI script residing on a server performs two important functions: Receives data from a Web browserReceives data from a Web browser Processes and formats the dataProcesses and formats the data CGI scripts can also be used to forward data to the proper destination, where it can be processed or stored CGI scripts can also be used to forward data to the proper destination, where it can be processed or stored

6 Diagramming a CGI Session

7 Parsing Data A Web form receives submitted user input A Web form receives submitted user input CGI scripting (or an alternative) parses the data CGI scripting (or an alternative) parses the data The browser sends user-submitted information to the Web server as a raw text string The browser sends user-submitted information to the Web server as a raw text string The basic element of a raw text string is a name=value pair The basic element of a raw text string is a name=value pair This raw text string consists of name=value pairs, delimited by ampersands (&) This raw text string consists of name=value pairs, delimited by ampersands (&) After the server receives this information, a CGI script can parse and format the raw text string into a human-readable format, or enter the data into a database After the server receives this information, a CGI script can parse and format the raw text string into a human-readable format, or enter the data into a database

8 Applied Example: FormMail FormMail details: FormMail details: Written by Matt WrightWritten by Matt Wright Extremely popularExtremely popular Used to e-mail information gathered from forms to a destination you specifyUsed to e-mail information gathered from forms to a destination you specify You install the script onto a Web server and refer to it in your formsYou install the script onto a Web server and refer to it in your forms Security concerns Security concerns Other versions of FormMail Other versions of FormMail

9 The Tag The tag creates a user-input Web form The tag creates a user-input Web form Encompassed all content and form fields Encompassed all content and form fields A container tag, requires closing tag A container tag, requires closing tag Attributes include: Attributes include: methodmethod “get”: not as secure, sends unencrypted text “get”: not as secure, sends unencrypted text “post”: encrypts, but can be easily broken “post”: encrypts, but can be easily broken actionaction Specifies the name and location of the CGI script used to process the form Specifies the name and location of the CGI script used to process the form

10 Web Form Fields User-input form fields include: User-input form fields include: Text boxText box Radio buttonRadio button Check boxCheck box Single-option select listSingle-option select list Multiple-option select listMultiple-option select list Scrolling text area boxScrolling text area box Password fieldPassword field File upload buttonFile upload button Submit and Reset buttonsSubmit and Reset buttons

11 Forms and the name Attribute All form field elements share one attribute: name All form field elements share one attribute: name Identifies information you receive from a user and associates it with a value you specifyIdentifies information you receive from a user and associates it with a value you specify Helps organize user inputHelps organize user input

12 Password Field Created using the password attribute of the tag Created using the password attribute of the tag Specify the size of the textbox using the size attribute Specify the size of the textbox using the size attribute Example: Example: Provides a field that allows password information to be entered and sent Provides a field that allows password information to be entered and sent Text entered by users masked by asterisks Text entered by users masked by asterisks

13 Text Boxes Used to collect a single line of data from the user, such as name, e-mail or address information Used to collect a single line of data from the user, such as name, e-mail or address information Syntax: Syntax: You can enter default text to appear in the form: You can enter default text to appear in the form: In this example, “DefaultText” would appear in the user’s window

14 File Upload Provides a Browse button and accompanying text box Provides a Browse button and accompanying text box Users click the Browse button and navigate to the file they want to upload Users click the Browse button and navigate to the file they want to upload The path to the file chosen by the user will appear in the text box The path to the file chosen by the user will appear in the text box Choose your file here: Choose your file here:

15 Submit and Reset Buttons Submit button Submit button Sends completed user information from Web form to serverSends completed user information from Web form to server Reset button Reset button Clears all information entered into form fields, instead of submitting information to serverClears all information entered into form fields, instead of submitting information to server All forms need a means to submit data All forms need a means to submit data

16 Radio Buttons A group of two or more mutually exclusive options A group of two or more mutually exclusive options Never used as stand-alone items Never used as stand-alone items Example: Example: Do you know carpentry? <input type=“radio” name=“Carpentry” value=“yes” To present a preselected radio button, add the following attribute and value: checked=“checked”

17 Check Boxes A group of non-exclusive choices A group of non-exclusive choices Syntax: Syntax: <input type="checkbox" name="groupName" <input type="checkbox" name="groupName"

18 Select Lists Drop-down lists of predetermined options Drop-down lists of predetermined options Created with the tag Created with the tag Two types: Two types: Single-option select list Multiple-option select listSingle-option select list Multiple-option select list To allow the user to select multiple options, add the multiple attribute in the tag To allow the user to select multiple options, add the multiple attribute in the tag

19 Scrolling Text Area Box Created by the element Created by the element Provides a scrolling text box into which a user can enter a few sentences, an address, a letter, etc. Provides a scrolling text box into which a user can enter a few sentences, an address, a letter, etc. Used to gather more than one line of text from the user Used to gather more than one line of text from the user Attributes include: Attributes include: colscols rowsrows wrapwrap Text between tags will appear to users as default text within the box Text between tags will appear to users as default text within the box


Download ppt "Site Development Foundations © 2004 ProsoftTraining All rights reserved."

Similar presentations


Ads by Google