CSE 102 Introduction to Web Design and Programming

Slides:



Advertisements
Similar presentations
/k/k 1212 Cascading Style Sheets Part one Marko Boon
Advertisements

HTML – A Brief introduction Title of page This is my first homepage. This text is bold  The first tag in your HTML document is. This tag tells your browser.
17/10/11. 2  The form element ( ) is used to include a number of form elements together so that they can be referenced by some other code in order to.
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.
XHTML II DIGITAL MEDIA: COMMUNICATION AND DESIGN F2007.
CS 142 Lecture Notes: HTMLSlide 1 Introduction There are several good reasons for taking CS142: Web Applications: ● You will learn a variety of interesting.
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.
XP Tutorial 6New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Creating Web Page Forms Designing a Product Registration Form Tutorial.
1 Creating Web Forms in HTML Web forms collect information from customers Web forms include different control elements including: –Input boxes –Selection.
Chapter 1 XHTML: Part I The Web Warrior Guide to Web Design Technologies.
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.
Objectives: 1. Create a Skeleton HTML 2. View a Skeleton File Through a Server and Browser 3. Learn HTML Body Tags for the Display of Text and Graphics.
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)
Images and Tables ables.asp.
CS3101 Internet Programming. Chapter 01 Introduction to XHTML 2Internet Programming - Chapter 01:XHTML Slides based on: Programming the World Wide Web.
What is XHTML? XHTML stands for Extensible Hypertext Markup Language
Chapter 7 - Introduction to Common Gateway Interface (CGI)
CSE 102 Introduction to Web Design and Programming
CSE 102 Introduction to Web Design and Programming
Style Sheets.
CIS 228 The Internet 9/20/11 XHTML 1.0.
CSE 102 Introduction to Web Design and Programming
CSE 102 Introduction to Web Design and Programming
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
CS120 The Information Era TOPICS: CGI-Scripts 4/18/05
Styling with Cascading Stylesheets Very Quick Introduction
ISC440: Web Programming 2 Web Programming Revision
© 2017 Akhilesh Bajaj, All Rights Reserved
Introduction to PHP FdSc Module 109 Server side scripting and
CGI I: Basics Web Programming.
EXCEPTION HANDLING IN SERVER CLIENT PROGRAMMING
CX Introduction to Web Programming
JavaScript for Client-Side Computation and Data Validation
What is XHTML?.
XHTML Forms for Data Collection and Submission
HTML IV (Forms) Robin Burke ECT 270.
Using the Internet to publish data and applications
Introduction to Web programming
Basic XHTML Tables XHTML tables—a frequently used feature that organizes data into rows and columns. Tables are defined with the table element. Table.
Introduction to Programming the WWW I
Chapter 5 Introduction to XHTML: Part 2
XHTML 1 by Carsomyr.
CSE 102 Introduction to Web Design and Programming
Basic Contact Form user sends an
CSS – Cascading Style Sheet DOM – Document Object Model
Part 2 Setting up a web server the easy way
Perl Web Page – Just Enough
Chapter 13 - Dynamic HTML: Object Model and Collections
Introduction There are several good reasons for taking CS142: Web Applications: You will learn a variety of interesting concepts. It may inspire you to.
JavaScript: Functions
Basic HTML and Embed Codes
CS 142 Lecture Notes: Rails Controllers and Views
Web Design and Development
Instructor: Charles Moen
Stylin’ with CSS.
The University of Tulsa
Part 2 Setting up a web server the easy way
CS 142 Lecture Notes: Rails Controllers and Views
HTML and CSS MIS 2402 Jeremy Shafer Department of MIS
What is Perl? PERL--Practical Extraction and Report Language
Chapter 7 - JavaScript: Introduction to Scripting
Cascading Style Sheets
CS205 Tables & Forms © 2012 D. J. Foreman.
محمد احمدی نیا XHTML محمد احمدی نیا
CS205 Tables & Forms © 2008 D. J. Foreman.
Introduction to Cascading Style Sheets (CSS)
CGI I: Basics Web Programming.
CS205 Tables & Forms © 2004 D. J. Foreman.
Making your HTML Page Interactive
Creating Web Documents
Presentation transcript:

CSE 102 Introduction to Web Design and Programming Form Processing with CGI

Sparky & CGI First, everyone needs to setup their Sparky account for CGI Instructions at: http://www.sinc.sunysb.edu/helpdesk/weblevels.shtml#adv add a new directory called “cgi-bin” to your www directory in all HTML forms, you will reference your CGI programs using the URL: http://www.sinc.sunysb.edu/cgi-bin/cgiwrap/aesmaili/script.cgi instead of aesmaili use your Sparky login name instead of script.cgi use the name of the cgi script you wish to use For using perl (a scripting programming language) inside CGI programs, you must reference #!/usr/local/bin/perl

Hello.html <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Web Page with Forms</title> <link rel="stylesheet" type="text/css" href="./css/form.css" /> </head> <body> <p style="font-weight: bold; font-size: larger"> Complete this form:</p> <form method="post" action="http://www.sinc.sunysb.edu/cgi-bin/cgiwrap/????/hello.cgi"> <table width="400"> <tr> <td class="fla"><label for="name">Full Name:</label></td> <td><input id="name" name="name" size="35" /></td> </tr> <tr> <td class="fla"><label for="email">Email:</label></td> <td><input id="email" name="email" size="35" /></td> </tr> <tr> <td></td> <td><input type="submit" value="Send" /></td> </tr> </table> </form> </body> </html>

form.css td.fla { background-color: #d2dbff } form label, form option { font-family: Arial, Helvetica, sans-serif } form input, form select { background-color: #eef }

hello.cgi <?xml version="1.0" encoding="UTF-8" ?> #!/usr/local/bin/perl ## hello.cgi--a toy CGI program use CGI qw(:standard); ## cgi perl module var $name = param('name'); var $email = param('email'); print "Content-type: text/html\r\n\r\n"; print <<END; <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head><title>Hello</title></head> <body> <h3>Hello $name,</h3> <p>The email address you sent is</p> <p>$email</p> </body> </html> END hello.cgi

For the hello.cgi script Make sure it’s file permission is set to 755 same for cgi-bin directory Change the text color and background color for the page returned by the script

JoinClub.html <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Join club.com</title> <link rel="stylesheet" href="formtable.css" type="text/css" title="form" /> </head> <body> <h2>Join <tt>club.com</tt></h2> <form method="post" action="http://www.sinc.sunysb.edu/cgi-bin/cgiwrap/????/join.cgi" enctype="application/x-www-form-urlencoded">   <p style="font-weight: bold; font-size: larger">Join club.com</p> <table width="400"> <tr> <td class="fla" rowspan="1" colspan="1">   <label for="n">Full Name:</label></td> <td rowspan="1" colspan="1">   <input id="n" name="name" size="35" type="text" /></td>   </tr>   <label for="e">Email:</label></td>   <input id="e" name="email" size="35" type="text" /></td> <tr> <td rowspan="1" colspan="1" />   <input type="submit" value="Join Now" /></td>   </table>   </form> </body> </html> JoinClub.html

join.cgi #!/usr/local/bin/perl # join.cgi--Perl script for # sending email to the manager use CGI qw(:standard); ## cgi perl module var $err_msg = "", $club="ic.sunysb.edu"; var $subject = "-s 'New Member club.com'"; var $cmd="/bin/mail $subject ???\@$club"; var $email = param('email'); ## form data var $name = param('name'); #var $cmd="/bin/mail $subject $email"; var $xhtml_front = '<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">'; if ( ! $name ) ## $name is empty { $err_msg .= "<p>Name must be specified.</p>"; } if ( ! $email ) ## $email is empty { $err_msg .= "<p>Email must be specified.</p>"; if ( $err_msg ) { &error(); ## function call exit; ## terminate program ## mail notice to manager open(MAIL, "| $cmd"); print MAIL "Name: $name\n"; print MAIL "Email: $email\n"; print MAIL "to join $club"; close(MAIL); ## Send response to standard output print "Content-type: text/html\r\n\r\n"; print <<END; $xhtml_front <head><title>Thanks for Joining</title></head> <body style="background-color: white"> <h3>Thank you $name.</h3> <p>Welcome to club.com. Your membership will be processed shortly.</p> <p>We will email you at <code>$email</code> about your new membership at $club.</p> </body></html> END ####################################### sub error() { print "Content-type: text/html\r\n\r\n"; print "$xhtml_front\r\n"; print '<head><title>Error</title></head>'; print '<body style="background-color: white">'; print '<h3>Data Missing</h3>'; print "<p>$err_msg Please go BACK, make corrections, "; print 'and submit the form again.</p> </body></html>'; join.cgi

join.cgi (another way) #!/usr/local/bin/perl -- # join.cgi--Perl script for # sending email to the member use CGI qw(:standard); ## cgi perl module var $err_msg = "", $club="ic.sunysb.edu"; var $subject = "New Member club.com"; var $email = param('email'); ## form data var $myEmail = "YOUR_SPARKY_USERNAME\@ic.sunysb.edu"; var $cmd="/bin/mail $myEmail"; var $name = param('name'); var $xhtml_front ='<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">'; if ( ! $name ) ## $name is empty { $err_msg .= "<p>Name must be specified.</p>"; } if ( ! $email ) ## $email is empty { $err_msg .= "<p>Email must be specified.</p>"; if ( $err_msg ) { &error(); ## function call exit; ## terminate program ## mail notice to manager open(MAIL, "| $cmd, $email"); print MAIL "To: $email\n"; ## should be same as address above print MAIL "From: Name of sender\@from.com\n"; print MAIL "Sender: The Sender\@sender.com\n"; print MAIL "Subject: $subject\n"; print MAIL "\nName: $name\n"; print MAIL "Email: $email\n"; print MAIL "to join $club *****\n\n"; print MAIL "Browser: $ENV{'HTTP_USER_AGENT'}\n\n"; print MAIL "IP Address: $ENV{'REMOTE_ADDR'}\n\n"; print MAIL "Host: $ENV{'REMOTE_HOST'}\n\n"; close(MAIL); ## Send response to standard output print "Content-type: text/html\r\n\r\n"; print <<END; $xhtml_front <head><title>Thanks for Joining</title></head> <body style="background-color: white"> <h3>Thank you $name.</h3> <p>Welcome to club.com. Your membership will be processed shortly.</p> <p>We will email you at <code>$email</code> about your new membership at $club.</p> </body></html> END ####################################### sub error() { print "Content-type: text/html\r\n\r\n"; print "$xhtml_front\r\n"; print '<head><title>Error</title></head>'; print '<body style="background-color: white">'; print '<h3>Data Missing</h3>'; print "<p>$err_msg Please go BACK, make corrections, "; print 'and submit the form again.</p> </body></html>'; join.cgi (another way)