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.

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

Adding Dynamic Content to your Web Site
CGI Programming.
CIS101 Introduction to Computing Week 08. Agenda Your questions JavaScript text Resume project HTML Project Six This week online Next class.
Chapter 31 Basic Form-Processing Techniques JavaServer Pages By Xue Bai.
CGI Programming Part 2. Input Tags Many different ways of getting data from the user. The tag is used most often. has a type attribute –Specifies the.
Browsers and Servers CGI Processing Model ( Common Gateway Interface ) © Norman White, 2013.
A simple PHP application We are going to develop a simple PHP application with a Web interface. The user enters two numbers and the application returns.
Tutorial 6 Working with Web Forms
Python and Web Programming
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.
Tutorial 6 Forms Section A - Working with Forms in JavaScript.
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
1 ‘Dynamic’ Web Pages So far, we have developed ‘static’ web-pages, e.g., cv.html, repair.html and order.html. There is often a requirement to produce.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
JAVASCRIPT HOW TO PROGRAM -2 DR. JOHN P. ABRAHAM UTPA.
Chapter 9 Using Perl for CGI Programming. Computation is required to support sophisticated web applications Computation can be done by the server or the.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
CO1552 Web Application Development HTML Forms. Websites can be made more interactive by providing facilities for users to provide data To get user entered.
ITIS 1210 Introduction to Web-Based Information Systems Chapter 24 How Websites Work with Databases How Websites Work with Databases.
1 Forms A form is the usual way that information is gotten from a browser to a server –HTML has tags to create a collection of objects that implement this.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,
Robinson_CIS_285_2005 HTML FORMS CIS 285 Winter_2005 Instructor: Mary Robinson.
CP476 Internet Computing CGI1 CGI is a common way to provide for specific computations on server side, interactions with users, or access to databases.
Python CGI programming
USING PERL FOR CGI PROGRAMMING
Lecture # 6 Forms, Widgets and Event Handling. Today Questions: From notes/reading/life? Share Personal Web Page (if not too personal) 1.Introduce: How.
Tutorial 7 Creating Forms. Objectives Session 7.1 – Create an HTML form – Insert fields for text – Add labels for form elements – Create radio buttons.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Using Perl for CGI Programming.
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.
Chapter 6 Server-side Programming: Java Servlets
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
JavaScript - A Web Script Language Fred Durao
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.
Perl CGI What is "CGI"? Common Gateway Interface A means of running an executable program via the Web. Perl have a *very* nice interface to create CGI.
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.
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
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.
WWW: an Internet application Bill Chu. © Bei-Tseng Chu Aug 2000 WWW Web and HTTP WWW web is an interconnected information servers each server maintains.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
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.
Jan 2001C.Watters1 World Wide Web and E-Commerce Client Side Processing.
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
 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.
 2001 Prentice Hall, Inc. All rights reserved. Chapter 7 - Introduction to Common Gateway Interface (CGI) Outline 7.1Introduction 7.2A Simple HTTP Transaction.
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.
Basic Webpage Design HTML Forms. Objectives Learn how to use HTML to create a form. Explain the concept of forms Know the difference of GET and POST Discuss.
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.
Creating Forms on a Web Page. 2 Introduction  Forms allow Web developers to collect visitor feedback  Forms create an environment that invites people.
Introduction to CGI PROG. CGI stands for Common Gateway Interface. CGI is a standard programming interface to Web servers that gives us a way to make.
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
FORMS Explained By: Jasdeep Kaur. Lecturer, Department of Computer Application, PGG.C.G., Sector: 42, Chandigarh.
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)
University of Kansas Department of Electrical Engineering and Computer Science Dr. Susan Gauch April 21, 2005 I T T C Introduction to Web Technologies.
Ashima Wadhwa Java Script And Forms. Introduction Forms: –One of the most common Web page elements used with JavaScript –Typical forms you may encounter.
© 2004 D. J. Foreman T&F-1 CS205 Tables & Forms. T&F-2 ©2007 D. J. Foreman Tables.
The Common Gateway Interface (CGI) Pat Morin COMP2405.
How to Write Web Forms By Mimi Opkins.
Section 17.1 Section 17.2 Add an audio file using HTML
Forms, cont’d.
Creating Forms on a Web Page
Kevin Harville Source: Webmaster in a Nutshell, O'Rielly Books
Presentation transcript:

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 data to programs on a server. –Receive responses from programs on a server.

What is CGI? (cont) CGI is the interface between server programs and other software. CGI is not a Perl specific concept. Any language can produce CGI programs. Why Perl? –Perl provides a nice interface for creating CGI scripts.

How Does CGI Work? Phase 1: Create. Phase 2: Request/Execute. Phase 3: Respond/Display.

Phase 1 A CGI script is created. –e.g. a Perl program to do your taxes. The script is placed on a server. –Made executable. –Given appropriate permissions. A webpage is created and linked to the CGI script. –Webpage is the script’s interface to the world.

Phase 2 A person visits the webpage and submits a request to run the script. Browser contacts the server with the CGI script: –Asks to run the script. –Passes input parameters to the script. Server runs the script on the input parameters.

Phase 3 Script produces output in the form of HTML. Server takes the output and returns it to the web browser. Browser displays the output as an HTML page. –Page may reference other CGI scripts.

An Overview of the Process Server CGI Program Input/ Output Request HTML

Calling a CGI Program CGI programs are called from HTML files. A common/simple way is with the HREF attribute of the anchor ( ) tag. For example, DO IT

Returning the Output CGI programs must create HTML output to return to the client. –HTML is the common language between the client and the CGI program. Communication with client is through standard output. –Output goes to server and then goes to screen. Use print function to send HTML output to client.

HTML OUTPUT First line of HTML output must specify the type: –i.e. type of the content of the output. The type is usually text/html. For example, –print “Content-type: text/html\n\n”; There must be a blank line after the first line.

A Simple Example

More Powerful Interaction Many webpages gather information from their visitors. A more powerful interaction between CGI program and browser is needed. This interaction is provided by forms.

Forms A form is a collection of widgets in a web page. Solicit responses from the user. A form must include a submit button! When the submit button is clicked: –The CGI program specified in the form is contacted. –A string representation of the widgets’ values is sent to the server.

Form Values Remember a form’s values are sent to the server as a string. Represented as a sequence of name=value pairs: –name is the widget’s name. –value is the widget’s value. Values are textual only! –Other data types cannot be sent. Validity of values must be checked by CGI program.

Get vs. Post There are two ways to send a form’s values to a CGI program. Get is the default method. –Data string is attached to URL. –Seen in browser’s address bar. –Server removes string from URL. –Stored in environment variable, QUERY_STRING. Post is the optional method. –Data string is sent through standard input. –CGI program can simply read it. –Length of string is stored in environment variable, CONTENT_LENGTH.

Creating a Form tags are used to create a form. For example, …