_ TWF  _ Code Chap 31

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



# 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===========================================================


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>",


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


<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">



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

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

your message and start over. 



<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>


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


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!