Helping ordinary people create extraordinary websites!

How To Send Email With Perl, Part II

By Will Bontrager
2004-06-09

2. Checking For Required Fields
If a form is used to submit information to the script, it can have a hidden field name="required" with a value containing the field name(s) that are required to have information before the form can successfully be submitted. If more than one form field name is required, separate them with a comma. Example:

<input type="hidden" name="required"
value="firstname, email">

The subroutine CheckRequired ensures that all required form fields contain information. The subroutine also uses another subroutine, ValidEmail, to verify that the email address stored in $In{email} is a validly formatted address. If appropriate, subroutine CheckRequired presents an error message to the user.

Subroutine WebPageErrorMessage is where error message web pages are sent to the user's browser. You'll notice that the last line of the subroutine is

goto BOTTOM;

That lines tells the script to jump to the label named "BOTTOM" located near the bottom of the script. (The label could be named anything you please. By convention, it is all capital letters. I chose "BOTTOM" simply because it is descriptive of where the label is located.)

The goto label method is used instead of the exit() function so the script can run within mod_perl.



Tutorial pages:

Copyright 2004 Bontrager Connection, LLC


 1 Votes

You might also want to check these out:


Leave a Comment on "How To Send Email With Perl, Part II "
You must be logged in to post a comment.

Link to This Tutorial Page!


GET OUR NEWSLETTERS