The e-mail subroutine
print "<h1>Thank you for filling out the form</h1>";
$firstname = $value;
$to = $email;
In the example above I have added 7 lines (including the blank one) to the end of the program body. You will want to copy these lines, and append them to the body of test2.cgi. There are 2 ways to do this.
You will not need to run chmod again.
Once you have appended the additional lines to the body of test2.cgi you can try the form again. Be sure to enter your own email address on the testform.htm page, or else someone will get a very confusing message. When you submit the form, it will show you the same display as before. This time, however, if you check your e-mail after a few seconds, you will have a message from President Clinton.
Let's review the additional lines:
$to = $email;
This line simply copies the contents of the variable $email to the variable, $to.
$from = "clinton\@whouse.gov";
$amount = "He owes me $20.00";
I would get an error, because Perl would try to access an variable called $20.00. If I escaped the $ sign, like this:
$amount = "He owes me \$20.00";
Then the line would work fine.
This one is pretty straightforward.
$body = "The form was filled out by $firstname
$body = "The form was filled out by $firstname $lastname \n Thank you goes on another line.";
The \n character is a newline. When the double quotes contain an \n , they interpret it into a carriage return in Ascii (plain text). This works for e-mail, which is written in Ascii, but not for HTML. Remember that HTML does not care whether the source code is on one line or many. If you want to drop to a new line in HTML, you have to insert a <BR> or <P> tag.
&email( addressee , reply-to, subject, message body)
You could have bypassed the previous 4 commands and simply typed this:
&email($email,"clinton\@whouse.gov","subject of my first e-mail","This is line 1 \nThis is line 2");
However, I think it easier to edit and read if you assign the values seperatly, as we did in our program.