1 / 15

How does it work

CGI Script and Forms. How does it work. 5/2/12 Objectives:. Define a Common Gateway Interface. Identify the four elements necessary to process a Web form through CGI. Explain how form data is processed through CGI.

sylvia
Download Presentation

How does it work

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CGI Script and Forms How does it work

  2. 5/2/12 Objectives: • Define a Common Gateway Interface. • Identify the four elements necessary to process a Web form through CGI. • Explain how form data is processed through CGI. • Access the FormMail Web site and answer specific questions about this CGI script.

  3. Common Gateway Interface • To be truly functional, a form requires the use of a Common Gateway Interface (CGI) program to process the script. • CGI is the de facto standard, but other technologies can be used to process forms, such as Active Server Pages (ASP) and JavaServer Pages (JSP). • CGI programs use server-sided script. By contrast, client-side script is executed on the client computer or browser.

  4. Functions of the CGI Script • A CGI script residing on a server performs two important functions: • It receives data from a Web browser. • Then it processes and formats the data.

  5. Why use a CGI script? • Without some sort of CGI script running on the server, the server cannot receive the Web form data. • Most CGI scripts do more than just receive data; they also remove extraneous information (such as delimiters) and format the data.

  6. Examples • Storing information in a database. • Searching a database for a product. • Sending processed information back to the end user.

  7. Elements of a CGI Session • Web browser • CGI script (a file that contains a programming language such as Perl or PHP) • Web form • Web server, with a CGI interpreter Complete the Flowchart

  8. Parsing Data In this figure, a form allows the user to provide their name and e-mail address. When the user clicks Submit Query button, the browser sends the information entered in this form to the Web server as a raw text string.

  9. Parsing Data The basic element of a raw text string is a name=value pair. The name attribute of the <form> element organizes information input by the user into name=value pairs. This Web form organizes user input according to the following code: Enter Your Name: <input type="text" name="Name” size="40"/> Enter Your E-mail: <input type="text" name="Email” size="40"/>

  10. Raw Text String When the browser sends this data, it will use the name attribute values “Name” and “Email” as the basis for creating the raw text string. You can specify any words as name values. In this example, the server receives a raw text string that resembles the following: Name=Dimitri+Pappa&Email=student50@class.com What symbol delimits the entries? What symbol indicates a blank space?

  11. Useable Format • After the server receives this information, a CGI script can parse and format the raw text string into a human-readable format similar to the following: Name: Dimitri Pappas E-Mail: student50@class.com

  12. Common CGI Script: FormMail • Find out more! • Visit: www.scriptarchive.com/formmail.html • Copy and paste the assignment questions from the class web site and key your responses.

  13. Wrap Up • Today we have defined CGI, Common Gateway Interface, which is a program that processes and interprets information that is generated through a Web form. • The four necessary components to process a Web form are: • Web browser • CGI script (a file that contains a programming language such as Perl or PHP) • Web form • Web server, with a CGI interpreter

  14. The Process is as follows: • The form resides on a web server and is retrieved through a browser. • The user completes the form through the browser and uploads to the server. • The Web server processes the information, with the help of a CGI script and an interpreter. • The Web server sends the processed information back to the browser, where the end user receives a reply.

  15. FormMail Summary • FormMail has been in existence since 1997 and it is designed to receive information from a Web form. It is written in Perl, which allows developers to use a free CGI interpreter available in many places. Most modern operating systems allow the Perl interpreter to be installed, making Perl one of the more ubiquitous languages. The script then sends the form information to you via e-mail. It is available free of charge from Matt Wright’s Web site. It is easy to install and customize.

More Related