CGI Scripts. 2 GET n Form data forms query string and is appended to the URL of the script –Can be accessed by using the environment variable QUERY_STRING.

Slides:



Advertisements
Similar presentations
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Using Perl for CGI Programming.
Advertisements

Lecture 6/2/12. Forms and PHP The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input When dealing with HTML forms.
Browsers and Servers CGI Processing Model ( Common Gateway Interface ) © Norman White, 2013.
Chapter 31 Basic Form-Processing Techniques JavaServer Pages By Xue Bai.
HTTP HyperText Transfer Protocol. HTTP Uses TCP as its underlying transport protocol Uses port 80 Stateless protocol (i.e. HTTP Server maintains no information.
Browsers and Servers CGI Processing Model ( Common Gateway Interface ) © Norman White, 2013.
How does the server format the information it gives to the appln program? As environment variables and in standard input.
CGI. XML2 Common Gateway Interface n Georgia Tech 1995 Web Usage Survey –Perl % –C % –Shell Scripts - 8.1% –Tcl - Tool Commercial Language.
 2002 Prentice Hall. All rights reserved. 1 Chapter 6 – Introduction to the Common Gateway Interface (CGI) Outline 6.1 Introduction 6.2 Client and Web.
HTTP Hypertext Transfer Protocol. HTTP messages HTTP is the language that web clients and web servers use to talk to each other –HTTP is largely “under.
How the web works: HTTP and CGI explained
HTTP Presented By: Holly Mortinson Amy Drout Kyle Balmer & Matt Conklin.
PHP Scripts HTML Forms Two-tier Software Architecture PHP Tools.
1 Web Search Interfaces. 2 Web Search Interface Web search engines of course need a web-based interface. Search page must accept a query string and submit.
Definitions, Definitions, Definitions Lead to Understanding.
Session Management A290/A590, Fall /25/2014.
HTTP Overview Vijayan Sugumaran School of Business Administration Oakland 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.
Forms and PHP Dr. Charles Severance
Common Gateway Interface
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.
Chapter 9 Using Perl for CGI Programming. Computation is required to support sophisticated web applications Computation can be done by the server or the.
Overview A plain HTML document is static A CGI program is executed in real-time, so that it can output dynamic information. CGI (Common Gateway Interface)
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Internet Server Group zAndrew Kozarik - CGI zBrandon Zarzoza- C# zChris Young- Perl zLawrence M. - Python zJohn Hall - JSP zRay Skoog- TCL zChad Stadig-
Lecture 7 – Form processing (Part 2) SFDV3011 – Advanced Web Development 1.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
TCP/IP Protocol Suite 1 Chapter 22 Upon completion you will be able to: World Wide Web: HTTP Understand the components of a browser and a server Understand.
Maryam Elahi University of Calgary – CPSC 441.  HTTP stands for Hypertext Transfer Protocol.  Used to deliver virtually all files and other data (collectively.
USING PERL FOR CGI PROGRAMMING
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 7: HTTP and CGI Fundamentals of Web Programming.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Using Perl for CGI Programming.
Website Development with PHP and MySQL Saving Data.
Chapter 9: Perl and CGI Programming CGI Programming Acknowledgement: Some materials are taken from Teach Yourself CGI Programming with PERL 5 in a Week.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
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.
HTTP - Forms - AppEngine Jim Eng
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.
1-1 HTTP request message GET /somedir/page.html HTTP/1.1 Host: User-agent: Mozilla/4.0 Connection: close Accept-language:fr request.
Form Data Encoding GET – URL encoded POST – URL encoded
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.
Netprog 2002 CGI Programming1 CGI Programming CLIENT HTTP SERVER CGI Program http request http response setenv(), dup(), fork(), exec(),...
Google Application Engine Introduction Jim Eng with thanks to Charles Severance
Appendix E: Overview of HTTP ©SoftMoore ConsultingSlide 1.
Operating Systems Lesson 12. HTTP vs HTML HTML: hypertext markup language ◦ Definitions of tags that are added to Web documents to control their appearance.
WEB SERVER Mark Kimmet Shana Blair. The Project Web Server Application  Receives request for web pages or images from a client browser via the internet.
 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.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
 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.
World Wide Web Components Browsers and Servers CGI Processing Model (Common Gateway Interface) © Norman White, 2001.
Adapted from  2012 Prentice Hall, Inc. All rights reserved. 5 th ed: Chapter 2 and th ed: 4.11 SY306 Web and Databases for Cyber Operations.
PHP Security Ryan Dunn Jason Pack. Outline PHP Overview PHP Overview Common Security Issues Common Security Issues Advanced Security Issues Advanced Security.
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.
URL Encoding When data is entered on a Web page form, it must be encoded before it can be passed to some program for processing. Each element on the 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)
The Common Gateway Interface (CGI) Pat Morin COMP2405.
Chapter 7 - Introduction to Common Gateway Interface (CGI)
CS 330 Class 7 Comments on Exam Programming plan for today:
CGI I: Basics Web Programming.
Introduction to CGI and ajax
Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Introduction to CGI and ajax
Forms, cont’d.
Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Environment Variables
World Wide Web Components
CGI I: Basics Web Programming.
Presentation transcript:

CGI Scripts

2 GET n Form data forms query string and is appended to the URL of the script –Can be accessed by using the environment variable QUERY_STRING –Browser or server may truncate data that exceeds an arbitrary number of characters

CGI Scripts3 GET n GET request by client GET /cgi-bin/prog.pl?name= Bill+age=29 HTTP/1.0 Accept: www/source Accept: text/html Accept: text/plain User-Agent: Lynx/2.4 libwww/2.14

CGI Scripts4 GET n Can access CGI program with a query without using a form CGI program CGI program n Can also send extra path information –Usually file name CGI program CGI program

CGI Scripts5 POST n Query length is unlimited n Script reads from standard input n Can't create canned queries

CGI Scripts6 POST POST /cgi-bin/prog.pl HTTP/1.0 Accept: www/source Accept: text/html Accept: text/plain User-Agent: Lynx/2.4 libww/2.14 Content-type: application/x-www- form-urlencoded Content-length: 22 user=Larry+Bird&age=30

CGI Scripts7 Decoding Form Data n Determine request protocol by checking the REQUEST_METHOD environment variable –GET or POST –One script can work for both methods n If the protocol is GET, read query string from QUERY_STRING and/or the extra path information from PATH_INFO

CGI Scripts8 Decoding Form Data n If the protocol is POST, determine the size of the request using CONTENT_LENGTH and read that amount of data from the standard input n Split the query string on the '&' character, which separates key-value pairs –The format is key=value&key=value...

CGI Scripts9 Decoding Form Data n Decode the hexadecimal and '+' characters in each key-value pair n Create a key-value table with the key as the index

CGI Scripts10 Examples n Using forms with POST –Plain text n Guestbook – /user-cgi/guestbook.pl?add using the GET method, will present a form for you to enter information

CGI Scripts11 Examples n Guestbook – /user-cgi/guestbook.pl using the GET method, will display the actual guestbook file [guestbook.htm] –Can open guestbook file directly by accessing ~grosky/CSC691/CGIScripts/ Guestbook/guestbook.htm

CGI Scripts12 Examples n Guestbook –When form is submitted using the POST method, this program decodes the information and outputs a thank-you message

CGI Scripts13 Examples n Survey – /user-cgi/shopping.pl/start.htm – ~grosky/CSC691/CGIScripts/Hidden Fields/start.htm