1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 4 Working with the Web.

Slides:



Advertisements
Similar presentations
Numbers Treasure Hunt Following each question, click on the answer. If correct, the next page will load with a graphic first – these can be used to check.
Advertisements

3rd Annual Plex/2E Worldwide Users Conference 13A Batch Processing in 2E Jeffrey A. Welsh, STAR BASE Consulting, Inc. September 20, 2007.
Zhongxing Telecom Pakistan (Pvt.) Ltd
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Introduction to XHTML Programming the World Wide Web Fourth edition.
AP STUDY SESSION 2.
1 WORKING WITH 2007 WORD Part 1 Developed October 2007 with lots of help from.
1
1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 2 Getting Started.
Copyright © 2003 Pearson Education, Inc. Slide 3-1 Created by Cheryl M. Hughes The Web Wizards Guide to XML by Cheryl M. Hughes.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Using Perl for CGI Programming.
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
Copyright © 2003 Pearson Education, Inc. Slide 7-1 Created by Cheryl M. Hughes The Web Wizards Guide to XML by Cheryl M. Hughes.
1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 8 Managing End-User Sessions.
McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. Extended Learning Module D (Office 2007 Version) Decision Analysis.
Copyright © 2011, Elsevier Inc. All rights reserved. Chapter 6 Author: Julia Richards and R. Scott Hawley.
Manuscript Central Training Author Center Module 2.
Prepared by: Workforce Enterprise Services For: The Illinois Department of Commerce and Economic Opportunity Bureau of Workforce Development ENTRY OF EMPLOYER.
Local Customization Chapter 2. Local Customization 2-2 Objectives Customization Considerations Types of Data Elements Location for Locally Defined Data.
Process a Customer Chapter 2. Process a Customer 2-2 Objectives Understand what defines a Customer Learn how to check for an existing Customer Learn how.
Custom Services and Training Provider Details Chapter 4.
1 Click here to End Presentation Software: Installation and Updates Internet Download CD release NACIS Updates.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Windows XP Project An Introduction to Microsoft Windows XP and Office 2003.
Creating a Dreamweaver Web Page and Local Site
Photo Slideshow Instructions (delete before presenting or this page will show when slideshow loops) 1.Set PowerPoint to work in Outline. View/Normal click.
1.
1 School Administrators Guide Standards-based Report Card (SBRC) Special Access/Privileges for School Administrators Interim Reporting Interim Reporting.
Version 1.0 digitaloffice.intel.com Intel ® vPro Technology Intel ® Active Management Technology Setup and Configuration HP Laptop – Compaq 6910p Small.
Break Time Remaining 10:00.
Turing Machines.
1. 2 Its almost time to take the FCAT 2.0! Here are some important explanations and reminders to help you do your very best.
PP Test Review Sections 6-1 to 6-6
User Friendly Price Book Maintenance A Family of Enhancements For iSeries 400 DMAS from Copyright I/O International, 2006, 2007, 2008, 2010 Skip Intro.
Tables Tables provide a means of organising the layout of data
Svetlin Nakov Telerik Corporation
Creating Tables in a Web Site
EIS Bridge Tool and Staging Tables September 1, 2009 Instructor: Way Poteat Slide: 1.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 24.1 Test-Driving the Ticket Information Application.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 12 – Security Panel Application Introducing.
INTRODUCTION Lesson 1 – Microsoft Word Word Basics
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Office 2003 Integration Integrating Office 2003 Applications and the World Wide Web.
Exarte Bezoek aan de Mediacampus Bachelor in de grafische en digitale media April 2014.
23-Aug-14 HTML/XHTML Forms. 2 What are forms? is just another kind of XHTML/HTML tag Forms are used to create (rather primitive) GUIs on Web pages Usually.
24-Aug-14 HTML Forms. 2 What are forms? is just another kind of HTML tag HTML forms are used to create (rather primitive) GUIs on Web pages Usually the.
The World Wide Web. 2 The Web is an infrastructure of distributed information combined with software that uses networks as a vehicle to exchange that.
Sample Service Screenshots Enterprise Cloud Service 11.3.
Copyright © 2012, Elsevier Inc. All rights Reserved. 1 Chapter 7 Modeling Structure with Blocks.
 Copyright I/O International, 2013 Visit us at: A Feature Within from Item Class User Friendly Maintenance  Copyright.
CONTROL VISION Set-up. Step 1 Step 2 Step 3 Step 5 Step 4.
1 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt Synthetic.
Skills for Success with Microsoft® Office 2010
1 BRState Software Demonstration. 2 After you click on the LDEQ link to download the BRState Software you will get this message.
Dr. Alexandra I. Cristea HTML Dr. Alexandra I. Cristea
1 hi at no doifpi me be go we of at be do go hi if me no of pi we Inorder Traversal Inorder traversal. n Visit the left subtree. n Visit the node. n Visit.
Types of selection structures
Chapter 12 Working with Forms Principles of Web Design, 4 th Edition.
Essential Cell Biology
Clock will move after 1 minute
Chapter 11 Creating Framed Layouts Principles of Web Design, 4 th Edition.
Chapter 13 Web Page Design Studio
Physics for Scientists & Engineers, 3rd Edition
1.step PMIT start + initial project data input Concept Concept.
1 Decidability continued…. 2 Theorem: For a recursively enumerable language it is undecidable to determine whether is finite Proof: We will reduce the.
HTML Concepts and Techniques Fourth Edition Project 2 Creating and Editing a Web Page.
XP Tutorial 6New Perspectives on HTML and XHTML, Comprehensive 1 Creating Web Page Forms Designing a Product Registration Form Tutorial 6.
Robinson_CIS_285_2005 HTML FORMS CIS 285 Winter_2005 Instructor: Mary Robinson.
 2008 Pearson Education, Inc. All rights reserved Introduction to XHTML.
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.
Web Page Design Forms! Website Design. Objectives What forms can do The Attributes of the form tag Using Textboxes Textareas Checkboxes Radio buttons.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
Presentation transcript:

1 Copyright © 2002 Pearson Education, Inc.

2 Chapter 4 Working with the Web

3 Copyright © 2002 Pearson Education, Inc. Chapter Objectives l Describe the basic functions within the CGI.pm library that can generate HTML tags l Learn the different formats of the CGI.pm function syntax l Understand how to use forms to send data to CGI/Perl programs

4 Copyright © 2002 Pearson Education, Inc. Using CGI.pm to generate HTML l The CGI.pm module provides several functions that can be used to concisely output HTML tags. For example, $mypage=It is a New Day; print $mypage ; l Can also be written as: $mypage=It is a New Day; print start_html($mypage);

5 Copyright © 2002 Pearson Education, Inc. 3 Basic CGI.pm Modules l start_html creates starting HTML tags l header creates the MIME Content-type line l end_html creates ending HTML tags 1. #!/usr/bin/perl 2. use CGI ':standard'; 3. print header; 4. print start_html; 5. print ' '; 6. print 'Welcome humans to my site '; 7. print end_html;

6 Copyright © 2002 Pearson Education, Inc. Would output the following …

7 Copyright © 2002 Pearson Education, Inc. CGI.pm Basic Functions The various CGI/PM function accept 3 basic syntactic formats: »No argument formatfunctions that can be used without any arguments »Positional argument formatfunctions that can accept comma-separated arguments within parentheses »Name-value argument formatfunctions that accept parameters submitted as name-and-value pairs

8 Copyright © 2002 Pearson Education, Inc. No Argument Format l The Previous Example shows the start_html, header, end_html functions »You can place the 1 or more functions directly within a print statement »Would output

9 Copyright © 2002 Pearson Education, Inc. Some Single Argument Functions CGI.pm Function Example of UseExample Output Header - the MIME Content- type line print header;Content- type:text/html\n\n start_html Tags to start an HTML document print start_html; br output tag print br; hr generate horizontal rule print hr; end_html end an HTML document print end_html;

10 Copyright © 2002 Pearson Education, Inc. Positional Argument Format l Specify multiple arguments based on the position of the argument l For example

11 Copyright © 2002 Pearson Education, Inc. Some Positional Functions CGI.pm Functions Example of UseExample Output start_html() tags needed to start an HTML document. start_html(My Page); My Page h1() header level 1 tags. (also h2(), h3(), and h4() ) print h1(Hello There); Hello There strong() – output argument in strong. print strong('Now'); Now p() creates a paragraph. print p(Time to move); Time to move b() prints the argument in bold. print b('Exit'); Exit i() prints the argument in italics. print i('Quickly'); Quickly

12 Copyright © 2002 Pearson Education, Inc. Operating on Variables l Can concisely use functions with a single print statement: »print i('Please '),'come when I call you ', strong('immediately.'); l This code would output the following: » Please come when I call you immediately.

13 Copyright © 2002 Pearson Education, Inc. Consider the following example: 1. # !/usr/bin/perl 2. use CGI ':standard'; 3. print header, start_html(Positional Example), h1('Simple Math'); 4. print b('two times two='), 2*2; 5. print br, 'but ', b('four times four='), 4*4; 6. print br, 'Finally, ', b('eight times eight='), 8*8; 7. print end_html;

14 Copyright © 2002 Pearson Education, Inc. Would output The following

15 Copyright © 2002 Pearson Education, Inc. Name-Value Argument Format My Title l Can specify names and values as follows: l Would output the following:

16 Copyright © 2002 Pearson Education, Inc. Some name/value functions CGI.pm Function Example UsageExample Output start_html start HTML document print start_html({ -title=>my title, –bgcolor=>red }); my title img inserts an image print img({- src=>'myfile.gif', -alt=>picture}); a establishes links print a( { - href=>' 'Click Here'); Click Here font() creates … tags print font( { -color=>BLUE, – size=>4}, Lean, and mean.); Lean, and mean.

17 Copyright © 2002 Pearson Education, Inc. Example Name/Value Program 1. #!/usr/bin/perl 2. use CGI ':standard'; 3. print header; 4. print start_html({-title=>'New Day ', -bgcolor=>'yellow'}); 5. print 'Welcome One And ', i('All'); 6. print end_html;

18 Copyright © 2002 Pearson Education, Inc. Would Output The Following...

19 Copyright © 2002 Pearson Education, Inc. Input Data from HTML Forms l A common method to start CGI/Perl programs and pass them arguments. » Use form elements such as: – text areas, –check boxes, – selection lists, and –radio buttons »There are CGI.pm functions for each of these will describe the long-hand (not using CGI.pm)

20 Copyright © 2002 Pearson Education, Inc. Starting and Ending Forms HTML forms are created by using the HTML and tags. »Within these tags, you place various HTML form elements, such as text areas, check boxes, and radio buttons. »For example, perl-pgm.com/cgi- bin/stuff.cgi.. ---(Your FORM elements here).

21 Copyright © 2002 Pearson Education, Inc. Two primary arguments The tag has two primary arguments: »ACTION= - Specifies the URL of the CGI program to start when the form is submitted. »METHOD= - Defines the argument format that will be used to send data to the CGI/Perl program. – get appends the form arguments to the end of the Web address. –post sends the data as part of the body of the HTML document. –Will use post since get method may limit the amount of data you can send.

22 Copyright © 2002 Pearson Education, Inc. A Form Tag Example #!/usr/bin/perl use CGI ':standard'; print header, start_html(Sample Form); print ;perl-pgm.com/cgi- bin/stuff.cgi (Perl statements that output FORM. elements go here) print ;.

23 Copyright © 2002 Pearson Education, Inc. Form Submit/Reset Buttons l Submit buttons submits form or erases all input. »On submit the form, data is sent to the location specified in the ACTION= argument of the tag. »HTML for submit/reset l Output from Perl program as follows: print ;

24 Copyright © 2002 Pearson Education, Inc. Form Submit/Reset Buttons 1. #!/usr/bin/perl 2. use CGI ':standard'; 3. print header, start_html('A First Form'); 4. print '<FORM ACTION=" bin/C4/first.cgi" METHOD=POST>'; 5. print br, ' '; 6. print ' '; 7. print ' ', end_html;

25 Copyright © 2002 Pearson Education, Inc. Would output the following...

26 Copyright © 2002 Pearson Education, Inc. Setting Up Input Text Areas l Input Text Areas creates text boxes on forms. l HTML for Input Text boxes <INPUT TEXT TYPE=text SIZE=15 MAXLENGTH=20 NAME=color> l Output from Perl program as follows: print ; 15 character box 20 character max allowed sets a CGI variable called color

27 Copyright © 2002 Pearson Education, Inc. Receiving HTML Form Arguments l Within the receiving program use param() »Make sure CGI variable name in NAME= argument from form matches argument in param() function. »See following example,

28 Copyright © 2002 Pearson Education, Inc. Receiving HTML Form Arguments

29 Copyright © 2002 Pearson Education, Inc. Example sending text box data Here is a calling form with a text box: 1.#!/usr/bin/perl 2. use CGI ':standard'; 3. print header, start_html; 4. print ' '; 5. print 'Enter A Color '; 6. print ' '; 7. print br, ' '; 8. print ' '; 9. print, end_html; Sets CGI variable color Creates submit and reset buttons

30 Copyright © 2002 Pearson Education, Inc. Example sending text box data Here is a receiving CGI/Perl Program: 1. #!/usr/bin/perl 2. use CGI ':standard'; 3. print header; 4. print start_html("Color my Text"); 5. $userColor = param('color'); 6. print " "; 7. print 'Welcome to my World'; 8.print, end_html; Receives CGI variable color

31 Copyright © 2002 Pearson Education, Inc. Example Output

32 Copyright © 2002 Pearson Education, Inc. Sending Passwords l Can create text boxes as password areas instead of viewable text. »Letters entered within a password box are viewed as asterisks (*). » To create a password box, you set TYPE=password with the INPUT form element tag. »Not a secure method for transmitting passwords. Any data input is sent in clear text (nonencrypted). Anyone with network access could, potentially read the password being transferred.

33 Copyright © 2002 Pearson Education, Inc. Setting Up Input Text Areas l HTML for Input Text boxes <INPUT TYPE=password SIZE=15 MAXLENGTH=25 NAME=pass> l Output from Perl program as follows: print ; 15 character box 20 character max allowed sets a CGI variable called pass

34 Copyright © 2002 Pearson Education, Inc. Program that creates password box 1.#!/usr/bin/perl 2.use CGI ":standard"; 3.print header; 4.print start_html("Color my Text"); 5.print '<FORM ACTION=" bin/C4/checkpass.cgi" METHOD=POST>'; 6.print ' Enter password to see message '; 7.print '<INPUT TYPE="password" SIZE="15" NAME="passwd">'; 8.print br, '<INPUT TYPE=SUBMIT VALUE="Click To Submit">'; 9.print <INPUT TYPE=RESET VALUE="Erase and Restart">'; 10. print, end_html;

35 Copyright © 2002 Pearson Education, Inc. Receiving Perl Program 1. #!/usr/bin/perl 2. use CGI ":standard"; 3. print header; start_html('Check Pass'); 4. $password=param('passwd'); 5. if ( $password eq 'PerlOK' ) { 6. print 'You got the password do not tell anyone'; 7. } else { 8. print 'Sorry you do not know the password'; 9. print br, "You entered $password"; 10. } 11. print end_html;

36 Copyright © 2002 Pearson Education, Inc. Would output the following...

37 Copyright © 2002 Pearson Education, Inc. Text Areas l Similar to text boxes, except you can create multicolumn and multirow input areas. Green Can output from CGI/Perl program as follows: print ; print Green Number of rows Number of cols CGI variable name

38 Copyright © 2002 Pearson Education, Inc. Check Boxes l Small boxes on a form that create a check mark when the user clicks them. Play Baseball? Fish? l Can output from CGI/Perl program as follows: print Play Baseball?; print Fish?; CGI Variable name CGI Variable value Label next to check box

39 Copyright © 2002 Pearson Education, Inc. Coordinated Check Boxes l Creating check boxes that enable multiple boxes to be checked »Use a common NAME= CGI variable name. Play Baseball? Fish? Travel? If select multiple receive comma separate list. »E.g., bball, travel if 1rst and 3rd.

40 Copyright © 2002 Pearson Education, Inc. Example Checkbox & Text Area Form 1. #!/usr/bin/perl 2. use CGI ':standard'; 3. print header, start_html('Checkbox and Textarea'); 4. print ' '; 5. print 'What do you eat? '; 6. print ' Vegetables?'; 7. print ' Meat?'; 8. print ' Anything not moving?'; 9. print ' Any comments? '; 10. print ' '; 11. print 'Put Comments Here '; 12. print br, br; 13. print br, ' '; 14. print ' '; 15. print ' ', end_html;

41 Copyright © 2002 Pearson Education, Inc. Would Output The Following...

42 Copyright © 2002 Pearson Education, Inc. Radio Buttons l Small circles that similarly to check boxes. »Only one button can be selected at any given time. »The NAME argument must be the same for all radio buttons group. Play Baseball? Fish? Travel? CGI Variable name CGI Variable value Label next to radio button

43 Copyright © 2002 Pearson Education, Inc. Selection Lists l A box with a scrolling list of one or more items that can be highlighted and selected by the user » defines each option to display. » SIZE defines number to display w/o scrolling. »MULTIPLE allows > 1 one item to be selected A fine hotel A cheap motel! A tent in the parking lot Just give me a sleeping bag checked

44 Copyright © 2002 Pearson Education, Inc. Radio and Selection Form 1. #!/usr /bin/perl 2. use CGI ':standard'; 3. print header, start_html; 4. print ' '; 5. print "What do you want to do this summer? "; 6. print ' Play Baseball?'; 7. print ' Fish?'; 8. print ' Travel? '; 9. print " Where would you like to stay? "; 10. print ' '; 11. print ' A fine hotel'; 12. print ' A cheap motel!'; 13. print ' A tent in the parking lot'; 14. print ' Just give me a sleeping bag checked'; 15. print ' '; 16. print br, br, ' '; 17. print ' '; 18. print, end_html;

45 Copyright © 2002 Pearson Education, Inc. Would Output The Following...

46 Copyright © 2002 Pearson Education, Inc. Hidden Fields l Not displayed on the form. »Typically used by form-processing applications that use multiple form screens to store values. »By storing values in hidden fields, your application can remember things between screens. (Will discuss more later.)

47 Copyright © 2002 Pearson Education, Inc. Using CGI.pm Debug Mode l Can test your scripts before executing them with a browser. »If can use Telnet commands on the Web server (or have Perl installed on your PC), you » CGI.pm enables you to enter CGI variables and values from a command line. »Receive the output (usually HTML document)

48 Copyright © 2002 Pearson Education, Inc. Using CGI.pm Debug Mode - II l To start and send an argument to the password program can execute the following: perl checkpass.cgi passwd=PerlOK l Enclose blank spaces in quotation marks: perl checkpass.cgi passwd=Perl Not OK

49 Copyright © 2002 Pearson Education, Inc. Would output the following...

50 Copyright © 2002 Pearson Education, Inc. Off-line Mode l If not specify any arguments will enter offline mode. For example, perl checkpass l After you enter each CGI variable and value, on a UNIX Web server, press Ctrl-D (that is, press both the Ctrl key and the D key simultaneously) to exit. »(On a Windows system, exit the input mode by pressing Ctrl-Z).

51 Copyright © 2002 Pearson Education, Inc. Summary Several functions found in the CGI.pm library can be used to generate HTML tags. » You must explicitly connect to the CGI.pm library before you can use these functions. l HTML forms are the method most commonly used to start and pass data to CGI/Perl programs. »The ACTION argument within the tag indicates which CGI application to start when the form is submitted.

52 Copyright © 2002 Pearson Education, Inc. Summary l Form elements set name-value pairs used to send parameters to the CGI/Perl application. »The NAME= attribute defines the CGI variable name. Possible form elements include text boxes, text fields, check boxes, radio buttons, and selection lists. Use the param()CGI.pm function to receive arguments from forms. The variable name used as an argument to this function must match the NAME= attribute set in the form.