Download presentation
Presentation is loading. Please wait.
Published byEsmond Gallagher Modified over 9 years ago
1
10 1 Hidden Fields and E-Mail CGI/Perl Programming By Diane Zak
2
10 2 Objectives In this chapter, you will: Create a form using a CGI script Include a selection list in a form Use a hidden field to pass information from one script to another Send an e-mail message using a script
3
10 3 Introduction When a browser connects to a web server: –Connection or session is opened –After the server has fulfilled the request, the connection is closed Server maintains no information about the session –Will often need to have the server remember information about a session Hidden fields Cookies
4
10 4 The Sun Travel Web Pages
5
10 5 The Sun Travel Web Pages Selection list: –HTML form element –List box from which user can select a value or values. Reasons to use: –Less typing for user –Helps maintains data integrity
6
10 6 Planning the sun1.cgi Script
7
10 7 Coding the sun1.cgi Script
8
10 8 Creating a Hidden Field in a Script Like other form elements, a hidden field has both a key and a value –Can be used to save information that would normally be lost when the connection to the server is closed –Not visible on the form However visible in form’s source code –Syntax: print “ \n”;
9
10 9 Completed sun1.cgi Script
10
10 Planning and Coding the sun2.cgi Script
11
10 11 Using a Script to Send E-Mail Need the Mail::Sendmail module installed –whereis Sendmail.pm (UNIX) –Start Search Sendmail.pm (Windows)
12
10 12 Procedure for using the Mail::Sendmail module: –1. Enter use Mail::Sendmail; –2. Create a hash and assign a value to the appropriate keys below –3. Enter sendmail (hash); Using a Script to Send E-Mail keyvalue ToRecipient’s e-mail address FromSender’s e-mail address SubjectMessage subject SmtpSender’s SMTP server MessageMessage to send to recipient
13
10 13 Completed sun2.cgi Script
14
10 14 Summary A selection list is a list box from which the user can select a particular value or set of values. You can use a hidden field to pass information from one CGI script to another. Like other form elements, a hidden key has a key and value. –key and value are passed to the server like any other form element
15
10 15 Summary Unlike other form elements, a hidden field does not appear on the form. You can use the Mail::Sendmail module to send e-mail from a script. –Command: use Mail::Sendmail; Enter the information you want to send by e-mail in a hash. –keys: To, From, Subject, Smtp, and Message –Send e-mail: sendmail (hash);
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.