Chapter 18 The HTML Tag <FORM NAME = " form name " opt ACTION = " URL " METHOD = "POST | GET" ENCTYPE = " mimeType " opt TARGET = " Target Page or Frame.

Slides:



Advertisements
Similar presentations
Perl & Regular Expressions (RegEx)
Advertisements

ISBN Regular expressions Mastering Regular Expressions by Jeffrey E. F. Friedl –(on reserve.
CS 898N – Advanced World Wide Web Technologies Lecture 8: PERL Chin-Chih Chang
1 *Copyright © 2002 Pearson Education, Inc.. 2 Web Wizard’s Guide to CGI/Perl David Lash Chapter 3 Perl Basics.
JavaScript Forms Form Validation Cookies CGI Programs.
PERL Part 3 1.Subroutines 2.Pattern matching and regular expressions.
CSCI 116 Decisions & Validation. Overview Constants Boolean conditions Decision logic Form validation 2.
Regular Expressions Regular Expression (or pattern) in Perl – is a template that either matches or doesn’t match a given string. if( $str =~ /hello/){
CS 898N – Advanced World Wide Web Technologies Lecture 10: Examples of PERL and CGI Chin-Chih Chang
Tutorial 14 Working with Forms and Regular Expressions.
Guide To UNIX Using Linux Third Edition
Regular Expressions Regular Expression (or pattern) in Perl – is a template that either matches or doesn’t match a given string. if( $str =~ /hello/){
Scripting Languages Chapter 8 More About Regular Expressions.
XP Tutorial 14 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
1 Chapter 6 – Creating Web Forms and Validating User Input spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information.
Tutorial 14 Working with Forms and Regular Expressions.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Chapter 8 Cookies And Security JavaScript, Third Edition.
Regular Expressions Regular expressions are a language for string patterns. RegEx is integral to many programming languages:  Perl  Python  Javascript.
Linux+ Guide to Linux Certification, Third Edition
ITCS373: Internet Technology Lecture 5: More HTML.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
Approaches for creating dynamic web pages Server-side processing: Server receives a request, performs all processing necessary to create a dynamic web.
Perl: Lecture 2 Advanced RE & CGI. Regular Expressions 2.
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.
Overview A regular expression defines a search pattern for strings. Regular expressions can be used to search, edit and manipulate text. The pattern defined.
Regular Expressions for PHP Adding magic to your programming. Geoffrey Dunn
Introduction to sed. Sed : a “S tream ED itor ” What is Sed ?  A “non-interactive” text editor that is called from the unix command line.  Input text.
20-753: Fundamentals of Web Programming 1 Lecture 10: Server-Side Scripting II Fundamentals of Web Programming Lecture 10: Server-Side Scripting II.
CS 330 Programming Languages 10 / 02 / 2007 Instructor: Michael Eckmann.
JavaScript, Fourth Edition
CS 330 Class 9 Programming plan for today: More of how data gets into a script Via environment variables Via the url From a form By editing the url directly.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
 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.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607.
Part:2.  Keywords are words with special meaning in JavaScript  Keyword var ◦ Used to declare the names of variables ◦ A variable is a location in the.
Introduction to Programming the WWW I CMSC Winter 2004 Lecture 13.
XP Tutorial 7 New Perspectives on JavaScript, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
1 CGI (Common Gateway Interface) CmpE 587 Emir Bayraktar Onur Bük.
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)
Chapter 14 The HTML Tag
Chapter 17 Arrays Perl to denote an array, for = (10, 20, 30, 50); Array subscripts are number from 0. Array elements require scalar.
Regular Expressions.
Chapter 7 - Introduction to Common Gateway Interface (CGI)
Session 2 Basics of PHP.
CS 330 Class 7 Comments on Exam Programming plan for today:
Looking for Patterns - Finding them with Regular Expressions
Perl Programming Language Design and Implementation (4th Edition)
Chapter 4: Making Decisions.
In this session, you will learn about:
Project 9 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms.
Miscellaneous Items Loop control, block labels, unless/until, backwards syntax for “if” statements, split, join, substring, length, logical operators,
Chapter 4: Making Decisions.
Working with Forms and Regular Expressions
Input/Output Input/Output operations are performed using input/output functions Common input/output functions are provided as part of C’s standard input/output.
The relational operators
© Akhilesh Bajaj, All rights reserved.
WEB PROGRAMMING JavaScript.
Pemrosesan Teks Herika Hayurani Sept 19, 2006
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
Fundamentals of Python: First Programs
Homework Reading Programming Assignments Finish K&R Chapter 1
PolyAnalyst Web Report Training
JavaScript: Introduction to Scripting
The Selection Structure
Regular Expression: Pattern Matching
Web Forms.
Presentation transcript:

Chapter 18 The HTML Tag <FORM NAME = " form name " opt ACTION = " URL " METHOD = "POST | GET" ENCTYPE = " mimeType " opt TARGET = " Target Page or Frame " opt onSubmit = " eventHandler " opt onReset = " eventHandler " opt > formElement formElement n Name of Perl Script Transmission Method

Chapter 18 URLencoding Symbol Meaning & The ampersand separates the form's fields. = The assignment operator separates a field name from the user's response. + Plus signs are used to transmit spaces. % Hexadecimal notation is used to represent non-alphanumeric characters.

Chapter 18 URLencoding When the GET method is used the URLencoded information appears after the ?

Chapter 18 The GET Method The GET method is used to transmit data when the data string does not exceed 256 characters. The text field is only 12 characters. A Submit button is used to signal completion of the form.

Chapter 18 The GET Method The GET method passes the data through the QUERY_STRING key of the ENV hash.

Chapter 18 Decoding: GET Method 1. Obtain the Form Data: $form_data = $ENV{‘QUERY_STRING’}; 2. Convert ASCII Characters: $form_data =~ s/%([\dA-Fa-f][\dA-Fa-f])/ pack ("C", hex ($1))/eg; 3. Separate Field Name and Data: ($field_name, $name) = split (/=/, $form_data); 4. Remove Suspicious Characters: $name =~ s/[;<>\(\)\{\}\*\|'`\&\$!#:"\\]/\ $1/g; 5. Convert Plus Sign to Spaces: $name =~ s/[+]/\ $1/g;

Chapter 18 The POST Method The POST method displays a Security Warning box prior to submission of the form. A Submit button is used.

Chapter 18 The POST Method The POST method passes the data through the standard input device. The CONTENT_LENGTH key of the ENV hash is used to obtain the data’s size.

Chapter 18 Decoding: POST Method 1. Obtain the Form Data: $form_size = $ENV{'CONTENT_LENGTH'}; read (STDIN, $form_data, $form_size); 2. Convert ASCII Characters: $form_data =~ s/%([\dA-Fa-f][\dA-Fa-f])/ pack ("C", hex ($1))/eg; 3. Separate Field Name and Data: ($field_name, $name) = split (/=/, $form_data); 4. Remove Suspicious Characters: $name =~ s/[;<>\(\)\{\}\*\|'`\&\$!#:"\\]/\ $1/g; 5. Convert Plus Sign to Spaces: $name =~ s/[+]/\ $1/g;

Chapter 18 The if…else Statement if ( expression ) { statement 1 ; statement n ; } elsif ( expression ) optional { statement 1 ; statement n ; } else optional { statement 1 ; statement n ; } Perl uses the if…else statement for selection. A block of code, as denoted by {}, is required for each clause. Notice Perl’s use of elsif.

Chapter 18 The if..else Statement The Test Score page uses an if..else statement to determine the grade.

Chapter 18 The if…else Statement if ($per_correct >= 90 && $per_correct <= 100) {print "Grade: A \n"} elsif ($per_correct >= 80 && $per_correct < 90) {print "Grade: B \n"} elsif ($per_correct >= 70 && $per_correct < 80) {print "Grade: C \n"} elsif ($per_correct >= 60 && $per_correct < 70) {print "Grade: D \n"} else {print "Grade: F \n"} The if…else statement used to determine the grade.

Chapter 18 The unless Statement unless ( expression ) { statement 1 ; … statement n ; } Perl provides an unless statement that represents the inverse of an if statement without elsif or else clauses.

Chapter 18 The unless Statement The unless statement prints a message only when the pH is too high for Azaleas. unless($ph <= 5.5) {print "Sorry. Your pH is too high for Azaleas.\n"}

Chapter 18 Statement Modifiers statement if ( expression ); satement unless ( expression ); statement while ( expression ); statement until ( expression ); Perl provides four statement modifiers that we can use when we only need to execute a single statement.

Chapter 18 Statement Modifiers print "Small #($n) \n" if ($n <= 100); print "Small #($n) \n" unless ($n > 100); $n=10; print "Count $n \n" while ($n-- >0); $n=10; print "Count $n \n" until ($n-- ==0); Examples of Perl’s statement modifiers.

Chapter 18 Matching Operators Matching $ scalar =~ m/ regex / options $ scalar =~ / regex / options Not Matching $ scalar !~ m/ regex / options $ scalar !~ / regex / options Perl contains matching and Not matching operators

Chapter 18 Substitution/Transliteration Substitution $ scalar =~ s/ pattern / replacement / options Transliteration $ scalar =~ tr/ pattern / replacement / options $ scalar =~ y/ pattern / replacement / options Perl contains substitution and transliteration operators.

Chapter 18 Splitting and Searching Splitting ( scalar list ) = split(/ pattern /, $ scalar array = split(/ pattern /, $ scalar ); array = grep(/ pattern array ); Perl contains splitting and searching functions.

Chapter 18 Regular Expressions Regular Expressions are created with: Quantifiers which are used to control repetition. Constructs which are built-in pattern sets. The regular expression object also contains methods for searching and matching.

Chapter 18 Quantifiers QuantifierMeaning * Match zero or more times. + Match one or more times. ? Match zero or one. { n } Match exactly n times. { n,} Match at least n times. { n, m } Match at least n times but no more than m times ( ) Override precedence [ ] Pattern set \ CharacterMatch a meta character. ^ Match at beginning $ Match at end. Match any character except new line | Match either character on left or on right.

Chapter 18 Constructs ConstructMeaning \d Match digits \D Do not match digits \w Match Word: letters, digits, underscore \W Do not match words \s Match "white space" (space, \n, \t, \r, \f) \S Do not match white space \b Match Word boundary (letters only) \B Do not Match Word boundary (letters only)

Chapter 18 The Regular Expressions Page

if ($hash{'string'} =~ /$hash{'expr'}/gi) { print "A match occured. \n"; print "Before Match: $` \n"; print "Matched String: $& \n"; print "After Match: $' \n"; } else {print "No match occured. \n"; } print " Parenthesized Expressions \n"; print "\$1: $1 \n"; print "\$2: $2 \n"; print "\$3: $3 \n"; print "\$4: $4 \n";