Skip to Main Content
Perl for Web Site Management
book

Perl for Web Site Management

by John Callender
October 2001
Beginner content levelBeginner
528 pages
15h 20m
English
O'Reilly Media, Inc.
Content preview from Perl for Web Site Management

Creating the HTML Form

Among the things Lincoln explains in his documentation is how you can use CGI.pm not only to process the output of HTML forms, but to actually produce those forms in the first place. With this approach, you just send a user to your CGI script, and the first time the user invokes the script it delivers an HTML form with all the values set to their defaults. Then, when the form is submitted back to the same script, it takes the data supplied by the user and does whatever you want it to do.

CGI.pm has lots of nifty features like that, but they tend to be a bit overwhelming for beginners, so in this case we’re going to take a more straightforward approach and simply create our form as a standard HTML page, then submit it to our CGI script for processing.

Example 3-1 shows an HTML form you can use for this demonstration. I’m not going to bother explaining what’s going on with the table tags and form elements in this web page; again, I’m assuming you already know about those things, or can learn about them elsewhere.

You can download your own copy of this web page from this book’s online example repository, at http://www.elanus.net/book/.Or you can just create your own copy of it.

Example 3-1. A page with an HTML form for testing a CGI form-to-email gateway

<HTML> <HEAD> <TITLE>Sample Form</TITLE> </HEAD> <BODY> <H1>Sample Form</H1> <P>Please fill out this form and submit it. Thank you.</P> <FORM ACTION="mail_form.cgi" METHOD="POST"> <TABLE> <TR> <TD ALIGN="right"><STRONG>My ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Web Client Programming with Perl

Web Client Programming with Perl

Clinton Wong
Embedding Perl in HTML with Mason

Embedding Perl in HTML with Mason

Ken Williams, Dave Rolsky

Publisher Resources

ISBN: 1565926471Catalog PageErrata