#!/usr/local/bin/perl # ############################### ## mailform ################################ # Get info from form and parse it # (this is a standard way of handling input from forms) # the next line shows how to get the input from a GET # $raw_data = $ENV{'QUERY_STRING'}; # # This script uses method=post, so here's how that is done read(STDIN, $raw_data, $ENV{CONTENT_LENGTH}); # for POST # the following does the parsing $items = split('&', $raw_data); for ($i = 0; $i < $items; $i++) { ($key,$value) = split('=', $_[$i]); $value =~ tr/+/ /; $value =~ s/%(..)/pack("C", hex($1))/eg; $data{"$key"} = $value; } # mail program opened with a pipe - note that it is set to send to the # "To:" and "Cc:" addresses by using the "-t" $mailprog = "/usr/lib/sendmail -t"; # check for "valid" e-mail address - at least xxx@yyy $atsign = "\@"; if (!($data{email} =~ /$atsign/)){$data{email} = "";} # what the above says is "if there wasn't an "@" in the # email address, make it blank". It will fail the next # test, and put out the "Oops" page asking for a vaild e-mail # address. $mdash = "\-"; if (!($data{fvidentifier} =~ /$mdash/)){$data{fvidentifier} = "";} # what the above says is "if there wasn't an "-" in the # first virtual ID, make it blank". It will fail the next # test, and put out the "Oops" page asking for a vaild first virtual ID ######################################################## # # Check for required fields, if not, put out "Oops" page # # This demo requires that the name, e-mail address, and # comments fields be filled in. # # The next line says, in effect "if name and e-mail and # comment are there, process it, otherwise skip to "Oops" # page output, where the missing ones will be flagged." # ( "&&" means "and") if ($data{name} && $data{email} && $data{fvidentifier} && $data{over18} && $data{consent}) { # # all required info is there, so do ################# MAILING STUFF ########################### $maildone = ".\n"; # end of mail input open(MAIL, "| $mailprog") || die "Can't open mailprog $mailprog, stopped"; # output mail lines print MAIL "From: mailform\@glamazon.com\n"; # who from print MAIL "To: transfer\@card.com,subscribe\@glamazon.com\n"; # to First Virtual print MAIL "Subject: $data{email} ($data{name}) Subscription Request\n"; print MAIL "\n"; print MAIL "BUYER: $data{fvidentifier}\n"; print MAIL "SELLER: char-Make Me Very Rich!\n"; $amount = 40; print MAIL "AMOUNT: ",$amount,".00\n"; print MAIL "CURRENCY: USD\n"; print MAIL "DESCRIPTION: Peek Of The Week Archives"; print MAIL "\n"; print MAIL "TRANSFER-ID: <",time," ",$data{email}," (",$data{name},")>\n"; print MAIL "\n"; print MAIL "Hi,\n"; print MAIL "Thanks for your order!\n"; print MAIL "Authorize this transaction, and I'll set up your userID and password.\n"; print MAIL "You can reach me at romana\@glamazon.com. - Romana\n"; print MAIL $maildone; # end messing by sending a "." and return to mail close(MAIL) || die "mail pipe exited $?"; ########################## # Display "Thank You" page print < Thank You

Thank you for your interest and thanks for using this form, $data{name}.

First Virtual will contact you via email, to ask you to authorize this transaction.

NEWPAGE #################################################### # This does the processing for missing required fields on the form # The line will print if the entry is missing, that's what the # "if (!....)" part checks for - the "!" means "no" or "not", so # print " - your name.
" if (!$data{name}); # is saying "print the line '- your name' if there was no name" # } else { print "Content-type: text/html\n\n"; print "Oops..."; print ""; print "

Oops!...

"; print "I didn't get that!
"; print "If you would like to access the archives, I need:
"; print " - your valid First Virtual account identifier.
" if (!$data{fvidentifier}); print " - your name.
" if (!$data{name}); print " - your e-mail address, in the form \"name\@host\"
" if (!$data{email}); print " for example: myname\@myprovider.com
" if (!$data{email}); print " - your statement that you are of age.
" if (!$data{over18}); print " - your consent to view adult material.
" if (!$data{consent}); print "Please try again...

Thanks...


"; } # End of "else" block # All done, get out exit;