SlideShare a Scribd company logo
Sending Data  Using an Online Form CISIWEB 430A
Objectives In this unit, you will Plan and create a CGI script that processes form data Learn how to prevent Perl from creating undeclared variables in a script Declare (create) scalar variables in a script Use assignment statements to assign values to existing variables Send form data to a script using GET and POST Improve the appearance of numbers displayed on a Web page
<html> <head> <title>Chapter 3 - Parsing Data</title> </head> <body bgcolor=&quot;#FFFFFF&quot;> <form action=&quot;http://myServer/parse2.cgi&quot; METHOD=POST> Comment <input type=&quot;text&quot; name=&quot;myComment&quot;> <p> <input TYPE = &quot;submit&quot; value = &quot;Submit&quot;> <input TYPE = &quot;reset&quot; VALUE = &quot;Start Over&quot;> </p> </form> </body> </html> #!/usr/bin/perl use CGI qw(:standard); print &quot;Content-type: text/html\n\n&quot;; print &quot;<HTML><HEAD><TITLE>Chapter 3&quot;; print &quot; - Output</TITLE></HEAD><BODY>\n&quot;; print param('myComment'); print &quot;</BODY></HTML>&quot;;
Planning the script Plan the HTML page Plan the logic for the script Plan the information the script will output
Accessing Form Data In an HTML form, the keys are the names of the form elements, and the values are the information (usually) entered by a user.  When the user presses the “Submit” button, the data are automatically transmitted to the script.  Once the data are sent, our script needs to parse the data so that we can use it.  If we use the CGI.pm module, parsing the data from a form is identical to parsing the data from a hyperlink.
Creating the Form Use HTML to create the form FORM tag contains instructions Action = location of .cgi Method = Get or Post Submit – calls the action to happen Controls – include a name attribute
Get vs. Post GET appends the form data to the end of the URL specified in the action property and is similar to sending the data through a hyperlink POST sends the data as a separate data stream, allowing the Web server to receive the data through “STANDARD INPUT”
Including special characters This project uses a dollar sign, which can’t be typed in directly (why not?) Characters that are given special meaning within a regular expression Backslash if you want to use literally :. * ? + [ ] ( ) { } ^ $ | \  Any other characters automatically assume their literal meanings.
Using printf Printf function is used for displaying data on a Web page Allows you to format the information  Allows you to specify the number of decimal places Allows you to display a + or – before the number Syntax: printf formatstring, list; List is a comma separated list of items Formatstring contains text and one or more format fields
Parts of a format field % - required, at the beginning of a format field Modifier – optional (+ or – to denote a positive or negative number) Minimum field width – option, sets a min number of characters to display Precision – optoin, expressed as a period followed by a number, the number of digits to the right of the decimal Format type – required – d (decimal) or f (floating point)

More Related Content

PDF
tabulatr2 – Index Tables for Lazy People
PPTX
Developer Conference 11-6-13
PDF
Web Data & Reporting Zipline – FME Summer Camp
PPTX
Data Wrangling Without Coding
PPT
Datatable Y Column
PPTX
Dynamic visualforce components in Salesforce
PPT
Ch 5 boolean logical in alice
PDF
Indigo Beverage
tabulatr2 – Index Tables for Lazy People
Developer Conference 11-6-13
Web Data & Reporting Zipline – FME Summer Camp
Data Wrangling Without Coding
Datatable Y Column
Dynamic visualforce components in Salesforce
Ch 5 boolean logical in alice
Indigo Beverage

Viewers also liked (7)

PDF
CAT CGI Trucks
PDF
Indigo Ga Aqua
PDF
Cooley Blues
PDF
Indigo Storyboards Comps 2010
PDF
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
PDF
SEO: Getting Personal
PDF
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
CAT CGI Trucks
Indigo Ga Aqua
Cooley Blues
Indigo Storyboards Comps 2010
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
SEO: Getting Personal
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Ad

Similar to Sending data in cgi (20)

PPT
Component and Event-Driven Architectures in PHP
PPTX
HTML5 Web Forms
PPT
Vb.Net Web Forms
ODP
Forms With Ajax And Advanced Plugins
PPT
Website Integration with QuickBase - Joshua McGinnis
PPTX
forms.pptx
ODP
Web Developement Workshop (Oct 2009) Slides
PPTX
Lecture 3 Introduction to HTML FORM AND CSS.pptx
PPTX
Working with data.pptx
PPT
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PDF
Web Development Course: PHP lecture 2
PPT
Dynamic Struts Forms
PDF
HSC INFORMATION TECHNOLOGY CHAPTER 1 ADVANCED WEB DESIGNING PART III.pdf
PPT
Xhtml Part2
PPTX
Html forms
PPTX
PPTX
Unit - III.pptxbgffhjxfjdfjfgjnsnsnshdhsjsksjsjsjsjsjsjsjsjsldksk
PPTX
Unit - III.pptxbgffhjxfjdfjfgjnsnsnshdhsjsksjsjsjsjsjsjsjsjsldksk
PPT
ASP.NET 10 - Data Controls
Component and Event-Driven Architectures in PHP
HTML5 Web Forms
Vb.Net Web Forms
Forms With Ajax And Advanced Plugins
Website Integration with QuickBase - Joshua McGinnis
forms.pptx
Web Developement Workshop (Oct 2009) Slides
Lecture 3 Introduction to HTML FORM AND CSS.pptx
Working with data.pptx
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
Web Development Course: PHP lecture 2
Dynamic Struts Forms
HSC INFORMATION TECHNOLOGY CHAPTER 1 ADVANCED WEB DESIGNING PART III.pdf
Xhtml Part2
Html forms
Unit - III.pptxbgffhjxfjdfjfgjnsnsnshdhsjsksjsjsjsjsjsjsjsjsldksk
Unit - III.pptxbgffhjxfjdfjfgjnsnsnshdhsjsksjsjsjsjsjsjsjsjsldksk
ASP.NET 10 - Data Controls
Ad

More from Chaffey College (20)

PPT
Strings Objects Variables
PPT
Ruby Chapter 2
PPTX
Social networks and games
PPT
Serious games
PPT
Chapter 05
PPT
Chapter 04
PPT
Chapter 03
PPTX
The games factory 2 alien wars
PPTX
Target markets
PPT
Ch 8 introduction to data structures
PPT
Ch 8 data structures in alice
PPT
Ch 7 recursion
PPTX
Intro to gml
PPT
Power point unit d
PPT
Power point unit c
PPT
Power point unit b
PPT
Power point unit a
PPT
Gamegraphics
PPT
Gamesound
PPT
Ch 6 text and sound in alice
Strings Objects Variables
Ruby Chapter 2
Social networks and games
Serious games
Chapter 05
Chapter 04
Chapter 03
The games factory 2 alien wars
Target markets
Ch 8 introduction to data structures
Ch 8 data structures in alice
Ch 7 recursion
Intro to gml
Power point unit d
Power point unit c
Power point unit b
Power point unit a
Gamegraphics
Gamesound
Ch 6 text and sound in alice

Sending data in cgi

  • 1. Sending Data Using an Online Form CISIWEB 430A
  • 2. Objectives In this unit, you will Plan and create a CGI script that processes form data Learn how to prevent Perl from creating undeclared variables in a script Declare (create) scalar variables in a script Use assignment statements to assign values to existing variables Send form data to a script using GET and POST Improve the appearance of numbers displayed on a Web page
  • 3. <html> <head> <title>Chapter 3 - Parsing Data</title> </head> <body bgcolor=&quot;#FFFFFF&quot;> <form action=&quot;http://myServer/parse2.cgi&quot; METHOD=POST> Comment <input type=&quot;text&quot; name=&quot;myComment&quot;> <p> <input TYPE = &quot;submit&quot; value = &quot;Submit&quot;> <input TYPE = &quot;reset&quot; VALUE = &quot;Start Over&quot;> </p> </form> </body> </html> #!/usr/bin/perl use CGI qw(:standard); print &quot;Content-type: text/html\n\n&quot;; print &quot;<HTML><HEAD><TITLE>Chapter 3&quot;; print &quot; - Output</TITLE></HEAD><BODY>\n&quot;; print param('myComment'); print &quot;</BODY></HTML>&quot;;
  • 4. Planning the script Plan the HTML page Plan the logic for the script Plan the information the script will output
  • 5. Accessing Form Data In an HTML form, the keys are the names of the form elements, and the values are the information (usually) entered by a user. When the user presses the “Submit” button, the data are automatically transmitted to the script. Once the data are sent, our script needs to parse the data so that we can use it. If we use the CGI.pm module, parsing the data from a form is identical to parsing the data from a hyperlink.
  • 6. Creating the Form Use HTML to create the form FORM tag contains instructions Action = location of .cgi Method = Get or Post Submit – calls the action to happen Controls – include a name attribute
  • 7. Get vs. Post GET appends the form data to the end of the URL specified in the action property and is similar to sending the data through a hyperlink POST sends the data as a separate data stream, allowing the Web server to receive the data through “STANDARD INPUT”
  • 8. Including special characters This project uses a dollar sign, which can’t be typed in directly (why not?) Characters that are given special meaning within a regular expression Backslash if you want to use literally :. * ? + [ ] ( ) { } ^ $ | \ Any other characters automatically assume their literal meanings.
  • 9. Using printf Printf function is used for displaying data on a Web page Allows you to format the information Allows you to specify the number of decimal places Allows you to display a + or – before the number Syntax: printf formatstring, list; List is a comma separated list of items Formatstring contains text and one or more format fields
  • 10. Parts of a format field % - required, at the beginning of a format field Modifier – optional (+ or – to denote a positive or negative number) Minimum field width – option, sets a min number of characters to display Precision – optoin, expressed as a period followed by a number, the number of digits to the right of the decimal Format type – required – d (decimal) or f (floating point)