2 1 Sending Data Using a Hyperlink CGI/Perl Programming By Diane Zak.

Slides:



Advertisements
Similar presentations
3.02D HTML Overview 3.02 Develop webpages.
Advertisements

The Web Warrior Guide to Web Design Technologies
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.
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.
Python and Web Programming
Guide To UNIX Using Linux Third Edition
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.
Chapter 2 Introduction to HTML5 Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
CGI Common Gateway Interface. CGI is the scheme to interface other programs to the Web Server.
Chapter 9 Using Perl for CGI Programming. Computation is required to support sophisticated web applications Computation can be done by the server or the.
1 Homework / Exam Exam 3 –Solutions Posted –Questions? HW8 due next class Final Exam –See posted schedule Websites on UNIX systems Course Evaluations.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Chapter 4 Handling User Input PHP Programming with MySQL 2nd Edition
XP Tutorial 6New Perspectives on HTML and XHTML, Comprehensive 1 Creating Web Page Forms Designing a Product Registration Form Tutorial 6.
1 Creating Web Forms in HTML Web forms collect information from customers Web forms include different control elements including: –Input boxes –Selection.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,
Links in HTML. Hyperlinks or links Millions of linked web pages make up the World Wide Web Used to connect a web page to another web page on the same.
1 HTML References: A HTML Tutorial: /HTMLPrimer.html
4 HTML Basics Section 4.1 Format HTML tags Identify HTML guidelines Section 4.2 Organize Web site files and folder Use a text editor Use HTML tags and.
Using Html Basics, Text and Links. Objectives  Develop a web page using HTML codes according to specifications and verify that it works prior to submitting.
Section 4.1 Format HTML tags Identify HTML guidelines Section 4.2 Organize Web site files and folder Use a text editor Use HTML tags and attributes Create.
Python CGI programming
Introduction to Programming the WWW I CMSC Summer 2004 Lecture 6.
10/5/2015CS346 PHP1 Module 1 Introduction to PHP.
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
 2008 Pearson Education, Inc. All rights reserved Introduction to XHTML.
Building PERL Scripts on a Windows system* *and running those scripts on an Apache server!
INTRODUCTION. What is HTML? HTML is a language for describing web pages. HTML stands for Hyper Text Markup Language HTML is not a programming language,
12 1 Redirection CGI/Perl Programming By Diane Zak.
HTML Internet Basics & Beyond. What The Heck Is HTML? HTML is the language of web pages. In order to truly understand HTML, you need to know a little.
Tutorial 10 Programming with JavaScript
4 1 Array and Hash Variables CGI/Perl Programming By Diane Zak.
9 1 DBM Databases CGI/Perl Programming By Diane Zak.
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.
11 1 Cookies CGI/Perl Programming By Diane Zak Objectives In this chapter, you will: Learn the difference between temporary and persistent cookies.
1 © Copyright 2000 Ethel Schuster The Web… in 15 minutes Ethel Schuster
CGI Common Gateway Interface. CGI is the scheme to interface other programs to the Web Server.
3 1 Sending Data Using an Online Form CGI/Perl Programming By Diane Zak.
7 1 User-Defined Functions CGI/Perl Programming By Diane Zak.
Introduction to JavaScript CS101 Introduction to Computing.
Introduction to Programming the WWW I CMSC Winter 2003.
5 1 Data Files CGI/Perl Programming By Diane Zak.
XP Tutorial 8 Adding Interactivity with ActionScript.
Sending data, forms and variables Please use speaker notes for additional information!
4 HTML Basics Section 4.1 Format HTML tags Identify HTML guidelines Section 4.2 Organize Web site files and folder Use a text editor Use HTML tags and.
10 1 Hidden Fields and CGI/Perl Programming By Diane Zak.
 2001 Prentice Hall, Inc. All rights reserved. Chapter 7 - Introduction to Common Gateway Interface (CGI) Outline 7.1Introduction 7.2A Simple HTTP Transaction.
HTML Basics. HTML Coding HTML Hypertext markup language The code used to create web pages.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Basic ActionScript and PHP Cis 126. Getting Started set up a basic folder structure so we can keep our files organized. Mirror this structure on your.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Sending data with CGI/Perl Please use speaker notes for additional information!
University of Kansas Department of Electrical Engineering and Computer Science Dr. Susan Gauch April 21, 2005 I T T C Introduction to Web Technologies.
Section 4.1 Section 4.2 Format HTML tags Identify HTML guidelines
Chapter 6 JavaScript: Introduction to Scripting
CGI I: Basics Web Programming.
3.00cs HTML Overview 3.00cs Develop webpages.
Introduction to Programming the WWW I
Introduction to XHTML.
Intro to PHP & Variables
Chapter 27 WWW and HTTP.
3.02D HTML Overview 3.02 Develop webpages.
3.02D HTML Overview 3.02 Develop webpages.
4.02A HTML Overview 4.02 Develop web pages using various layouts and technologies. (Note to instructor: HTML tags are in red only to differentiate from.
CGI I: Basics Web Programming.
Presentation transcript:

2 1 Sending Data Using a Hyperlink CGI/Perl Programming By Diane Zak

2 2 Objectives In this chapter, you will: Create a hyperlink to a CGI script Append data to a URL Use the CGI.pm module to parse data Access data using the param function

2 3 Introduction Changes to static web pages can only be made when the page is updated on the server –Requires human intervention Changes to dynamic web pages can be made in response to information sent through a hyperlink or form

2 4 Creating a Link to a Script Most web pages contain text, images and hyperlinks –Hyperlinks or links appear as different colored text, underlined text, or clickable images –The HTML anchor tag with the HREF property is used to create a link HREF = Hypertext Reference Syntax: hyperlinktext hyperlinktext is the clickable text is the syntax for a clickable image

2 5 Creating a Link to a Script

2 6 When creating a script, remember to: –Enter the shebang line (required for UNIX) –Enter a comment that includes the name of the script and the script’s purpose –Enter the Content-type line: print “Content-type: text/html\n\n”;

2 7 print Function Perl can generate HTML output in various ways: –print –printf –“here” documents Syntax for print: –print output; Output can be strings, functions, variables Output can be an expression or a list of expressions, separated by commas

2 8 print Function Using the newline character (\n) can make HTML code easier to read when viewing the HTML source in a browser –Without \n, the HTML code appears all on one line, and is difficult to read It is good practice to include all of the HTML tags - HTML, HEAD, and BODY

2 9 Completing a Script Remember that the following needs to be done for each Perl/CGI script that is created: 1. Save the document 2. cd path If UNIX - chmod 755 filename 3. perl -c filename 4. perl -w filename 5. Open the script in a web browser

2 10 Sending One Item of Data Using a Link Append the data to the URL –Use a question mark (?) to separate the URL from the data –Use an equal sign (=) to separate the key from the value –Syntax: hyperlinkText –key is the variable name One-word name –value is the value that is assigned to the key

2 11 Sending One Item of Data Using a Link When you have clicked on a link that is sending data, the data is viewable in the browser’s address box

2 12 Parsing Data Data can be sent through a URL, but the script has to be able to separate the key from the value This ability is part of the CGI.pm module –module = collection of prewritten code stored in a file –Most modules use the file extension.pm, which stands for perl module

2 13 Parsing Data Can find if you have cgi.pm by: –whereis cgi.pm (UNIX) –Start --> Search --> cgi.pm (Windows) –If not, can download from: software/WWW/cgi_docs.html

2 14 Parsing Data To use CGI.pm, you need to include the statement: –use CGI qw(:standard); qw = quote words Same as the statement - use CGI(‘:standard’); :standard is an import tag –Tells the Perl interpreter to allow the use of the standard features of the CGI.pm module Can find out more about CGI.pm, by typing: –perldoc CGI.pm

2 15 Parsing Data The param function accesses the value associated with a key –param is part of the standard features of CGI.pm –Syntax: param(key) where key is in single or double quotation marks Example: –param(‘state’); –param(“state”);

2 16 Parsing Data When checking for errors, using perl -w scriptname, you can: –Type key=value after the scriptname –Example: perl -w jackson.cgi state=Alabama

2 17 Parsing Data You can also type in key=value on a separate line –Example: perl -w jackson.cgi “(offline mode: enter name=value pairs on standard input)” message should appear Type in key=value pairs Type Ctrl+d (UNIX) or Ctrl+z (Windows) when done

2 18 Parsing Data If the offline mode message does not appear, the use CGI statement needs to be changed: –use CGI qw(:standard -debug); –This is including the -debug pragma, and tells CGI.pm to pause to let you type in the data pragma = special type of Perl module.

2 19 Parsing Data

2 20 Parsing Data

2 21 Sending Multiple Items of Data Using a Link When sending more than 1 item of data through a link, use the following syntax: <A HREF=URL?key1=value1&key2= value2...&keyN=valueN>hyperlinkText –An ampersand (&) is used to separate each key and value pair –Some browsers limit the amount of information that can be attached to a URL

2 22 Sending Multiple Items of Data Using a Link When sending a value that contains more than one word, substitute a plus sign (+) for a space –Example: Arkansas The jackson.cgi script, when sent that data can get the values of the state and cap keys using param –print “The capital of “, param(‘state’), “ is “, param(‘cap’), “.\n”; –The capital of Arkansas is Little Rock.

2 23 Sending Multiple Items of Data Using a Link

2 24 Summary The syntax for creating a hyperlink is: hyperlinkText –hyperlinkText is the clickable link The syntax for creating an image link is: –imagefile contains the path and name of the image file print output; can be used to generate HTML instructions. –output is an expression or list of expressions separated by commas

2 25 Summary To pass one item of data to a script, using a hyperlink, use the syntax: hyperlinkText –key is the variable name associated with the value To pass more than one item of data to a script, using a hyperlink, separate the key and value pairs with a &, with the syntax: <A HREF=URL?key1=value1&key2=value2...& keyN=valueN>hyperlinkText To pass a value that has a space in it, replace the space with a plus sign (+)

2 26 Summary The CGI.pm module can be used to parse data –use CGI qw(:standard); When testing the script from the command line, with perl -w, you can either: –Enter the data on the same line as the command –Enter each item of data on a separate line –You may need to use the -debug pragma You can use CGI.pm’s param function to access the value of a key that was passed to the script