_ TWF  _ Code Chap 31

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
HOME | BACK | NEXT | MENU | SEARCH | ORDER | COMMENT | HELPINFO -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

31code01.pl


#!/usr/local/bin/perl 

# the above is the standard 'magic' to inform the shell to feed this 

# file to the program named after the bang.

#

# simple CGI to intercept a form and mail the contents to the page's

# owner

#

# HTML4dummies Comment remailer

# 6/5/95 - singe@outer.net

# called by /html4dum/comment.html

#

require "/www/cgi-bin/formlib.pl";

                      # this executes the perl library script, 

                      # making the subroutines contained therein

                      # available to our script.



$| = 1;               # output NOT buffered - this prevents perl

                      # from buffering the script's output to STDOUT

                      # from being buffered -- since STDOUT is our

                      # conduit back to the user's browser, we want

                      # to ensure that our data gets out as we 

                      # create it. If the connection goes away while

                      # we still have data in memory, the user will

                      # never see it.



&GetFormArgs();       # parse FORM arguments (now in %in)



$ENV{PATH_INFO} ne '' && &GetPathArgs($ENV{PATH_INFO});

                      # the existence of the PATH_INFO environment

                      # variable and the successful parsing of the

                      # information contained within are the tests 

                      # that prove the CGI was called properly from

                      # a form



# both the preceding lines of code use sub-routines supplied in 

# Brigette Jellinek's excellent formlib.pl - a library of tools for 

# parsing form data into usable variables (see Chapter 15 for more

# info).



chop ($date = `/bin/date`);

                      # set the variable $date to the output of the

                      # UNIX program 'date', chopping the trailing 

                      # carriage return from the result



print "Content-Type: text/html\n\n";

                      # set the return document's MIME type



# [output page's title, header info, etc.]



open (COMMENT,"| /usr/bin/mailx -s \"HTML4DUM Comments: $in{subject}\" html4dum" );

# open filehandle which is a pipe to the UNIX mailx program, setting # the mail's subject and recipient



print COMMENT "$date:"; 

print COMMENT "Comments from: $in{name}\t($in{from})\n";

print COMMENT "\n$in{body}";

print COMMENT "\n===========================================================

========\n\n";

close (COMMENT);



# print date and explanatory infomation, and user's input to the 

# mail filehandle, closing it when done to ensure delivery.



print STDOUT "<H1>Thank you for your comments!</H1><P>",

             "You have submitted the following comments:<P>",

             "<HR><PRE>$in{body}</PRE><P>";



print STDOUT "<B>If you have purchased the book <I>HTML for

 Dummies</I> you can",

"<A HREF = \"registrn.html\"> register on-line!</A></B><P>",

"<ADDRESS>Sample form CGI by singe@outer.net<P>$date</ADDRESS>";



# finish off with the footer info




31code02.htm


<FORM METHOD="POST" ACTION="http://www.outer.net/cgi-bin/email.cgi">

Your Name: <INPUT NAME="name"><P>

Your Email Address: <INPUT NAME="email"><P>

<INPUT NAME="subject">Subject<P>

<INPUT NAME="recipient" VALUE="singe" TYPE="hidden">

<P>Text:<P>

<TEXTAREA NAME="content" ROWS=10 COLS=60></TEXTAREA> <P>

Click <INPUT TYPE="submit" VALUE="submit"> to submit your

message. Click <INPUT TYPE="reset" VALUE="reset"> to clear

your message and start over. 

</FORM>




31code03.htm


<FORM METHOD="POST" ACTION="http://machttp.outer.net/email.cgi">



<INPUT TYPE="hidden" NAME="recipient" VALUE="biffo@outer.net">

<INPUT TYPE="hidden" NAME="mailer" VALUE="mail.outer.net">



Your Name:<INPUT TYPE="text" NAME="user" SIZE="40" MAXLENGTH="40"><P>



Your E-Mail adddress:<INPUT TYPE="text" NAME="address" SIZE="40" MAXLENGTH="40"><P>



Subject:<INPUT TYPE="text" NAME="subject" SIZE="40" MAXLENGTH="40"><P>



<TEXTAREA NAME="message" ROWS=6 COLS=40></TEXTAREA><P>

<INPUT TYPE="Submit" VALUE="Send the message"> <INPUT TYPE="reset" VALUE="Reset">

</FORM>




-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
HOME | BACK | NEXT | MENU | SEARCH | ORDER | COMMENT | HELPINFO -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

E-Mail: The Web Foundations at twf@lanw.com
URL: http://www.lanw.com/twf/codech31.htm
Text - Copyright © 1995, Ed Tittel, Mark Gaither, Sebastian Hassinger, & Mike Erwin.
Web Layout - Copyright © 1995, LANWrights & IMPACT Online.
Revised -- February 15th, 1996 [James Michael Stewart - WebMaster - IMPACT Online]

HTML 2.0 Checked!