Data files using cgi/perl Please use speaker notes for additional information!

Slides:



Advertisements
Similar presentations
Computing Science Software Design and Development SOFTWARE DESIGN AND DEVELOPMENT USING PYTHON.
Advertisements

Computer Hardware 4 Main Types.
Write a program step by step. Step 1: Problem definition. Given the coordinate of two points in 2-D space, compute and print their straight distance.
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.
Limerick Checker Project Group Members: Jestin Ledlum Bryon Baumstarck Yining Wang.
CGI programming in Perl Learning Objectives: 1. To understand how a CGI program works in Perl and how to make it runnable in web browsers 2. To learn how.
What Data Do We Have? Sections 2.2, 2.5 August 29, 2008.
1 9/1/06CS150 Introduction to Computer Science 1 What Data Do We Have? CS 150 Introduction to Computer Science I.
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
Computing Theory: BBC Basic Coding Year 11. Lesson Objective You will: Be able to define what BBC basic is Be able to annotate BBC basic code Be able.
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.
DBM Databases Please use speaker notes for additional information!
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
Perl/cgi and an Access Database Please use speaker notes for additional information!
NETWORK CENTRIC COMPUTING (With included EMBEDDED SYSTEMS)
(c) Manzur Ashraf, Short course, KFUPM PHP & MySQL 1 Basic PHP Class 2.
1 HTML and CGI Scripting CSC8304 – Computing Environments for Bioinformatics - Lecture 10.
Chapter 6 Generating Form Letters, Mailing Labels, and a Directory
MAIL MERGE Designing Documents with. Terms Mail Merge: A process that inserts variable information into a standardized document to produce a personalized.
More JavaScript Examples Please use speaker notes for additional information!
ENTERING ELIGIBLE ENERGY RESOURCE APPLICATIONS IN DELAFILE Version 2.0 August 25, 2015.
CGI and Perl - Basics Please use speaker notes for additional information!
2 1 Sending Data Using a Hyperlink CGI/Perl Programming By Diane Zak.
Perl Web Page – Just Enough Pepper. Web site Set up the top of your script to indicate perl and plain text #!/usr/bin/perl print "Content-type:text/plain\n\n";
Building PERL Scripts on a Windows system* *and running those scripts on an Apache server!
Activating Clarity  Activating Clarity  Activation  Online Activation  Fax Activation  Review and Verify Activation and License Terms  Updating.
Mail with Perl/CGI Please use speaker notes for additional information!
4 1 Array and Hash Variables CGI/Perl Programming By Diane Zak.
1 Basic Perl CGI Programming. 2 Issues How and when your program is invoked. Generating Response –HTTP Headers –HTML (or whatever document type you want)
Address book By NIRMIT GANG. Main Program  Selection Screen 1.Enter Data 2. Read Data 3. Search Data 4. Modify Data 5. Delete Data 6. Exit Choice.
11 1 Cookies CGI/Perl Programming By Diane Zak Objectives In this chapter, you will: Learn the difference between temporary and persistent cookies.
Planning your site/organization on the Web Please use speaker notes for additional information!
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.
3 1 Sending Data Using an Online Form CGI/Perl Programming By Diane Zak.
Order Entry Program Please see speaker notes for additional information!
Functions Please use speaker notes for additional information!
Introduction to CGI/Perl Please use speaker notes for additional information!
HELLO WORLD program in COBOL - CIS12 Please use speaker notes for additional information!
5 1 Data Files CGI/Perl Programming By Diane Zak.
Sending data, forms and variables Please use speaker notes for additional information!
Intermediate CGI & CGI.pm Webmaster II - Fort Collins, CO Copyright © XTR Systems, LLC CGI Programming & The CGI.pm Perl Module Instructor: Joseph DiVerdi,
Introduction to ASP.NET Please use speaker notes for additional information!
Two Forms Please use speaker notes for additional information!
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.
IF statements - selection Please use speaker notes for additional information!
Introduction to Perl. What is Perl Perl is an interpreted language. This means you run it through an interpreter, not a compiler. Similar to shell script.
 2001 Prentice Hall, Inc. All rights reserved. Chapter 7 - Introduction to Common Gateway Interface (CGI) Outline 7.1Introduction 7.2A Simple HTTP Transaction.
Form Processing Week Four. Form Processing Concepts The principal tool used to process Web forms stored on UNIX servers is a CGI (Common Gateway Interface)
Maximum Profit Please use speaker notes for additional information!
Web Server Design Assignment #5: Unsafe Methods & CGI Due: 05/05/2010 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin.
CS 330 Class 8 Homework A pattern that contains a word with an optional period A pattern that contains Fred with a space (not Freddy) See regexp.txt guest4.htm.
File Handle and conditional Lecture 2. File Handling The Files associated with Perl are often text files: e.g. text1.txt Files need to be “opened for.
Connecting to the eTeacher FTP on Win XP eTeacherGroup 2010.
Sending data with CGI/Perl Please use speaker notes for additional information!
1 The Internet Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
University of Kansas Department of Electrical Engineering and Computer Science Dr. Susan Gauch April 21, 2005 I T T C Introduction to Web Technologies.
CS 330 Class 10 Programming plan for today: More files Saving data from a form.
Chapter 7 - Introduction to Common Gateway Interface (CGI)
CS120 The Information Era TOPICS: CGI-Scripts 4/18/05
CS 286 Computer Organization and Architecture
CGI I: Basics Web Programming.
Keyboard Input and Screen Display ––––––––––– Interactive Programming
BIAM 530 Innovative Education--snaptutorial.com
Perl Web Page – Just Enough
Microsoft Applications
Part 2 Setting up a web server the easy way
CSCI N207 Data Analysis Using Spreadsheet
CS 286 Computer Organization and Architecture
Mail Merge April 1, 2004.
CGI I: Basics Web Programming.
Presentation transcript:

Data files using cgi/perl Please use speaker notes for additional information!

Mailing List Mailing List Enter Name: Enter Address: Enter City: Enter State: Enter ZIP:

#!/usr/bin/perl #maillist.cgi - saves name and address information to make a mailing list use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/html\n\n"; use CGI qw(:standard); use strict; #declare variables my ($name, $stadr, $city, $state, $zip); #assign variables $name = param('name'); $stadr = param('stadr'); $city = param('city'); $state = param('state'); $zip = param('zip'); #save form data to a file open(FILEOUT, ">>", "maillist.txt") or die "file error: maillist.txt. $!, stopped"; print FILEOUT "$name, $stadr, $city, $state, $zip\n"; close(FILEOUT); print " Record just entered \n"; print " \n"; print "$name, $stadr, $city, $state, $zip\n"; print " \n";

#!/usr/bin/perl #maillist.cgi - saves name and address information to make a mailing list use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/html\n\n"; use CGI qw(:standard); use strict; #declare variables my ($name, $stadr, $city, $state, $zip); #assign variables $name = param('name'); $stadr = param('stadr'); $city = param('city'); $state = param('state'); $zip = param('zip'); #save form data to a file open(FILEOUT, ">>", "maillist.txt") or die "file error: maillist.txt. $!, stopped"; print FILEOUT "$name, $stadr, $city, $state, $zip\n"; close(FILEOUT); print " Record just entered \n"; print " \n"; print "$name, $stadr, $city, $state, $zip\n"; print " \n"; FILEOUT is opened to append (this is indicated by the >>. The name of the file is maillist.txt. The error line will catch problems opening the file. The record that is written to the file contains all of the fields that were inputted on the html form and then stored in variables in this code.

#!/usr/bin/perl #maillistrd.cgi - reads the mail list file use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/html\n\n"; use CGI qw(:standard); use strict; #declare variables my ($name, $stadr, $city, $state, open(INF, "<", "maillist.txt") or die "file error: maillist.txt. $!, ; close(INF); print " Records on mail list \n"; print " \n"; print " Mailing list: \n"; foreach my $record { chomp($record); ($name, $stadr, $city, $state, $zip) = split(/,/, $record); print "$name, $stadr, $city, $state, $zip \n"; } print " \n"; This code reads the records on the maillist.txt file I then by going through each record individually using the foreach which establishes $record as an individual record

Degree CIS Degree Options in CIS Which option are you enrolled in? Webmaster Programming Networking Multimedia and the Internet Business Information Systems Information Systems Transfer Computer Science Transfer

#!/usr/bin/perl #degreeopts.cgi - saves form data to a file and reports results use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/html\n\n"; use CGI qw(:standard); use strict; #declare variables my = (0, 0, 0, 0, 0, 0, 0); #assign variables $option = param('option'); #save form data to a file open(FILEOUT, ">>", "totals.txt") or die "file error: totals.txt. $!, stopped"; print FILEOUT "$option\n"; close(FILEOUT); Notice that each record on the file contains only the $option.

#read file and accumulate totals in an array open(FILEIN, "<", "totals.txt") or die "file error: totals.txt. $!, ; close(FILEIN); #display contents of array on screen foreach my { chomp($record); $options_total[$record]= $options_total[$record]+1; } print " CIS Degree Options \n"; print " \n"; print " Information about degree options in the CIS department. \n"; print " \n"; print " Number of students in CIS Degree options: \n"; print " Webmaster $options_total[0] \n"; print " Programming $options_total[1] \n"; print " Networking $options_total[2] \n"; print " Multimedia and the Internet $options_total[3] \n"; print " Business Information Systems $options_total[4] \n"; print " Information Systems Transfer $options_total[5] \n"; print " Computer Science Transfer $options_total[6] \n"; print " \n";