CS 898N – Advanced World Wide Web Technologies Lecture 6: PERL and CGI Chin-Chih Chang

Slides:



Advertisements
Similar presentations
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Advertisements

CGI & HTML forms CGI Common Gateway Interface  A web server is only a pipe between user-agents  and content – it does not generate content.
Video, audio, embed, iframe, HTML Form
Browsers and Servers CGI Processing Model ( Common Gateway Interface ) © Norman White, 2013.
1 HTML Markup language – coded text is converted into formatted text by a web browser. Big chart on pg. 16—39. Tags usually come in pairs like – data Some.
JavaScript Forms Form Validation Cookies CGI Programs.
Creating Web Page Forms. Objectives Describe how Web forms can interact with a server-based program Insert a form into a Web page Create and format a.
Tutorial 6 Working with Web Forms
Forms Review. 2 Using Forms tag  Contains the form elements on a web page  Container tag tag  Configures a variety of form elements including text.
Gathering Requirements What do users want?. Information Gathering Techniques Surveys Interviews Focus Groups.
Forms Describe common uses of forms on web pages
USER INTERACTIONS: FORMS
Tutorial 6 Working with Web Forms. XP Objectives Explore how Web forms interact with Web servers Create form elements Create field sets and legends Create.
Using Entities & Creating Forms Jill R. Sommer Institute for Applied Linguistics Kent State University.
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
Creating Web Page Forms
Tutorial 6 Forms Section A - Working with Forms in JavaScript.
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
INTRODUCTION TO WEB DATABASE PROGRAMMING
4-Sep-15 HTML Forms Mrs. Goins Web Design Class. Parts of a Web Form A Form is an area that can contain Form Control/Elements. Each piece of information.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
XP Tutorial 6New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Creating Web Page Forms Designing a Product Registration Form Tutorial.
XP Tutorial 6New Perspectives on HTML and XHTML, Comprehensive 1 Creating Web Page Forms Designing a Product Registration Form Tutorial 6.
CO1552 Web Application Development HTML Forms. Websites can be made more interactive by providing facilities for users to provide data To get user entered.
1 Creating Web Forms in HTML Web forms collect information from customers Web forms include different control elements including: –Input boxes –Selection.
Forms and Form Controls Chapter What is a Form?
Web111a_chapt06.ppt HTML: Section 6 Forms HTML tags: define data input and/or output Define the Input and/or Output on the web page Do not process the.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
Project Four Forms Discuss form processing Describe the difference between client-side and server-side form processing Add a horizontal rule to a Web page.
Internet / Intranet Fall 2000 Class 7. Brandeis University Internet/Intranet Spring Class 7 Agenda Project / Homework Discussion Forms Validating.
Internet / Intranet CIS-536 Class 7. 2 HTML Forms A Method to Allow Users to Pass Information to a CGI Script Forms Allow Information to Be Entered Via:
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
1 HTML References: A HTML Tutorial: /HTMLPrimer.html
Robinson_CIS_285_2005 HTML FORMS CIS 285 Winter_2005 Instructor: Mary Robinson.
Python CGI programming
Introduction to Programming the WWW I CMSC Summer 2004 Lecture 6.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
USING PERL FOR CGI PROGRAMMING
CSC 2720 Building Web Applications HTML Forms. Introduction  HTML forms are used to collect user input.  The collected input is typically sent to a.
Copyright © 2004 ProsoftTraining, All Rights Reserved. Lesson 7: Web Forms.
Chapter 8 Collecting Data with Forms. Chapter 8 Lessons Introduction 1.Plan and create a form 2.Edit and format a form 3.Work with form objects 4.Test.
Website Development with PHP and MySQL Saving Data.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
ITCS373: Internet Technology Lecture 5: More HTML.
XHTML & Forms. PHP and the WWW PHP and HTML forms – Forms are the main way users can interact with your PHP scrip Typical usage of the form tag in HTML.
Tutorial 6 Working with Web Forms. XP Objectives Explore how Web forms interact with Web servers Create form elements Create field sets and legends Create.
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
7 Chapter Seven Client-side Scripts. 7 Chapter Objectives Create HTML forms Learn about client-side scripting languages Create a client-side script using.
HTML Form Widgets. Review: HTML Forms HTML forms are used to create web pages that accept user input Forms allow the user to communicate information back.
HTLM Forms CS3505. Form Handling in Browser html User Files out form WEbBROWSErWEbBROWSEr User read response submit Get URL?input html Get file html script.
+ FORMS HTML forms are used to pass data to a server. begins and ends a form Forms are made up of input elements Every input element has a name and value.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
Form Processing Week Four. Form Processing Concepts The principal tool used to process Web forms stored on UNIX servers is a CGI (Common Gateway Interface)
HTML Forms. A form is simply an area that can contain form fields. Form fields are objects that allow the visitor to enter information - for example text.
HTML III (Forms) Robin Burke ECT 270. Outline Where we are in this class Web applications HTML Forms Break Forms lab.
HTML Structure II (Form) WEEK 2.2. Contents Table Form.
Lesson 11. CGI CGI is the interface between a Web page or browser and a Web server that is running a certain program/script. The CGI (Common Gateway Interface)
XP Tutorial 6New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Creating Web Page Forms Designing a Product Registration Form Tutorial 6.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
How to Write Web Forms By Mimi Opkins.
Introducing Forms.
CGI Programming Part II UNIX Security
Lesson 6: Web Forms.
Presentation transcript:

CS 898N – Advanced World Wide Web Technologies Lecture 6: PERL and CGI Chin-Chih Chang

PERL and CGI (PERL) PERL (Practical Extraction and Report Language) is a text processing language that runs in the background on servers to deliver up Web content in a fashion that is invisible to the viewer. PERL was invented by a man named Larry Wall as as much improved version of awk.

PERL and CGI (awk) awk is a standard UNIX command set and is an advanced text processing utility used for text search and replacement on a large scale. A, w, and k are the initials of Aho, Kernighan and Weinberger who wrote the first version of awk back in the 1970s.

PERL and CGI PERL was around before JavaScript, VBScript, and Active Server Pages, and was initially responsible for all programming enhancement to HTML. CGI (Command Gateway Interface) is the interface offered by a Web server to pass on form data to an external application. The application processes the data and often sends back the results to the client browser.

PERL and CGI PERL is used to write CGI scripts. CGI scripts are the programs that process the information submitted in HTML form submissions. Forms can be used for anything from spawning an automatic to database searches and electronic storefronts. The power of PERL can support any and all of these activities.

Download PERL Freeware versions of PERL are available at There are two ways to install PERL: –Download the source and compile it. –Download the binaries (executables) and run the install batch. To download the binaries, go to reference.perl.com. reference.perl.com

Installing PERL for Windows To download PERL for Windows: –Select the Win32 freeware version. The ActiveState version is also available and has a load of extra features but it is not free. –Download perl bindist04-bc.zip and libwin zip. perl bindist04-bc.zip libwin zip –Unzip the perl5 file, then the install.bat under DOS. Add the PERL/bin directory to your path as instructed in the readme.win32 file. Then unzip the libwin file and run its install.bat.

CGI Works with PERL The problem that CGI solves is what to do with user input from an HTML form. The solution has been programmed into HTML by means of the form tag combined with the submit button. The submit button causes two specific actions to occur: –The data from the form is placed into environment variables. –The CGI script named in the form tag action = “scriptname” parameter is executed. CGI scripts are written in PERL.

CGI Works with PERL The contents of any and all environment variables are available within PERL and used as textual data in PERL statement. The way to access these variables is to write a reference as below: $ENV(variables) The form tag method parameter specifies either get or post as the mechanism through which the user input is transferred to the environment variables.

GET and POST Both methods format the user input date in the same way. The difference between them is in how that data is retrieved by PERL. HTML form input consists of several options for user input: the text box, radio button, checkbox, and select group. User input from these options is paired up in the format name=value.

GET and POST Spaces in the value side are placed with + symbols and the pairs. Here is an example: name=Bill+Gates&company=Microsoft This string would be generated by a form with two text input boxes. The get and post methods need a CGI script to send the data to.

GET and POST The form tag has its method and action parameters as follows: The.pl extension means this is a PERL script and cgi-bin is the directory where these are usually located. In UNIX, bin is short for binary. Here we have a form that will format the user input, load it into environment variables, and transfer control to cgi-bin/signup.pl.

GET and POST (The Get Method) Get is the default CGI method so if no method is specified, get will be used. When the get method is executed, the CGI data is formatted in two pieces, separated by a “?”. –The contents of the action =parameter –The formatted user input This is then used to set the next URL for the Web browser, causing control to be transferred to the script.

GET and POST (The Get Method) The formatted user input is also placed in the environment variable named QUERY_STRING from where the PERL script can read it. This is limited to 1024 characters. This would look like: cgi-bin/signup.pl? name=Bill+Gates&company=Microsoft The user input show in the preceding code would give this result.

GET and POST (The Post Method) The form tag in the post method would look like this: <form method=“post” action=“cgi-bin/signup.pl”> Post directs the formatted user input into standard input buffer, which is commonly called stdin.

GET and POST (The Post Method) For PERL to access this, it opens stdin and reads the line. This data get transferred from the browser form elements to the server through HTTP. In the post method, the content-length and other environment variables are included in the header.

GET and POST (The Post Method) There is no limit to the size of the post string. In the CGI string of the post method special characters that have specific meaning in PERL are encoded as a hexadecimal value preceded by a % sign.

CGI Input Controls There are various types of input controls in the form method. Given an example of buying a car, we might have the following input types. The text box: –If the user enters porsche boxster, it will be returned as model=porsche+boxster.

CGI Input Controls The radio button: <input type=radio name=color value=silver checked> –The radio box uses the value given in the input tag, returning color=silver.

CGI Input Controls The checkbox: < input type=checkbox name=tires value=goodyear> < input type=checkbox name=tires value=bose> –If nothing is checked, nothing is returned. If no value is specified, true will be used. This set could return tires=goodyear.

CGI Input Controls The select box: air conditioning leather seats global positioning system

CGI Input Controls –The select box will return 0 or more pairs for options selected. If no value parameter, the value returned will be the text of the option. –The select box multiple attribute permits multiple selections. If more than one option is selected there will be only be one pair returned, but the value side will have all the selections separated by “\0”. The selections in the preceding example would return extras=air+conditioning\0leather+seats\0gps.

CGI Input Controls The submit button: <input type=submit name=“Buy the car!” value=buyit> The submit button will be included as well and will give you a Buy+the+car%21=buyit.

Writing Perl Scripts Perl is an interpreted language. Perl scripts, like scripts in other interpretive languages, are compiled on the fly when they are run. Though there are tons of Perl resources online, we have to modify them to fit our particular domain name, addresses, our host’s directory structure, and whatever files we are accessing on the server.

An Example CGI/Perl Translation We use the HTML in Figure 9.4 as an example. This form contains three tables: –one for the user identification –one for the product selection –one for the credit card input The CGI action is given in this form tag, which starts near the beginning and ends at the bottom of the page.

An Example (HTML Form) There are three hidden input fields declared: the recipient, the subject, and the URL for the CGI script to link to after it has sent the