perlquestion
sulfericacid
<p>Using the script below, a simple mailing form, I was wondering if anyone could assist me in setting up a file upload for sending. I know I am not the best coder and some of you like to be rude and start yelling at me for how I wrote it, but please keep those comments to yourself from now on. This is the best I can do and would prefer not being mocked.
</p>
<p>
Thing is I am on a public webhost and I don't have access to any non-so-popular modules so keep that in mind. I'd prefer not using any modules, if possible, or rewriting the way the script is setup for mailing.
</p>
<p>
Please let me know what I should look up on or if you have a snipplet that will work, it would be greatly appreciated!
</p>
<readmore>
<code>
#!/usr/local/bin/perl
###### SpyderForm v1.0 ######
## Created by Aaron Anderson ##
## sulfericacid@qwest.net ##
## website: http://secretrealmofme.hypermart.net/webstuff ##
## Please read the readme file prior to installation. ##
## If you cannot find readme, dl a copy from my site! ##
use strict;
# Let's have some fun my'ing things, shall me?
my %form;
my $sendmail;
my $webmaster;
my $yourname;
my $thanks;
use CGI;
my $query = CGI->new;
print $query->header;
%form = %{$query->Vars};
##################### BEGIN EDITING THIS SECTION #############################
$sendmail = "/var/qmail/bin/qmail-inject";
$webmaster = 'sulfericacid@qwest.net';
( $thanks = <<'END_OF_THANKS' ) =~ s/^\s+//gm ;
Thank you for visiting my website! Things are always
changing so I hope you pop back again! If you asked
any questions, please allow upto 24 hours for a response.
END_OF_THANKS
$yourname = 'Aaron';
# $signame = 'Aaron Anderson\n';
# $sigurl = 'www.yourdowmain.com\n";
#################### STOP EDITING FOR NOW #####################################
### Make sure things are being completed, die slackers!
if ($webmaster eq "") {
print "Webmaster, please include your email address!\n";
}
if ($form{'usermail'} eq "") {
print "Ok, buddy, how do you expect me to email you back if you FORGET to leave yoru email address?!?\n";
}
if ($form{'username'} eq "") {
print "Please click back and type in your name so I can spy on you!\n";
}
if ($form{'message'} eq "") {
print "Only a severe slacker would try to submit a form without leaving a message!\n";
}
# Mail to Webmaster
open (MAIL, '|-', "$sendmail -t") or die $!;
print MAIL "To: $webmaster\n";
print MAIL "From: $form{'usermail'}\n";
print MAIL "Subject: Insert subject here!\n\n";
print MAIL "Name- $form{'username'}\n";
print MAIL "Url- $form{'userweb'}\n";
print MAIL "Message- $form{'message'}\n";
print MAIL "Ip- $ENV{'REMOTE_ADDR'}\n";
close (MAIL);
# Mail to User
open (MAIL, '|-', "$sendmail -t") or die $!;
print MAIL "To: $form{'usermail'}\n";
print MAIL "From: $form{'weburl'}\n";
print MAIL "Subject: Thank you for signing my form!\n\n";
print MAIL "$thanks\n";
print MAIL "You said:\n";
print MAIL "$form{'message'}\n";
close (MAIL);
# Let's give them something to look at, might as well, they were nice enough to fill out the form!
####################### BEGIN EDITING HERE 2 ######################################
print <<end_of_results;
<html>
<head>
<title>Results Page</title>
</head>
<table width="75%" border="0">
<tr>
<td colspan="2">
<p>Thank you for filling out the form. If you are awaiting assistance and
you asked a question, please allow upto 24 hours for my to get back to
you.</p>
<p>- $yourname</p>
</td>
</tr>
<tr>
<td colspan="2"><font color="#9933CC">Here is a copy of what you sent...</font></td>
</tr>
<tr>
<td width="9%"><font color="#666666">name:</font></td>
<td width="91%"><font color="#999999">$form{'username'}</font></td>
</tr>
<tr>
<td width="9%"><font color="#666666">email:</font></td>
<td width="91%"><font color="#999999">$form{'usermail'}</font></td>
</tr>
<tr>
<td width="9%"><font color="#666666">url:</font></td>
<td width="91%"><font color="#999999"><a href="$form{'weburl'}">$form{'weburl'}</a></font></td>
</tr>
<tr>
<td width="9%"><font color="#666666">message:</font></td>
<td width="91%"><font color="#999999">$form{'message'}</font></td>
</tr>
<tr>
<td width="9%"><font color="#666666">Rec. IP:</font></td>
<td width="91%"><font color="#999999">$ENV{'REMOTE_ADDR'}</font></td>
</tr>
<tr>
<td width="9%"> </td>
<td width="91%"> </td>
</tr>
</table>
end_of_results
</code>
<p>
<font size="1">
<b>edited:</b> Tue Oct 15 17:12:35 2002
by [jeffa] - added readmore tag <code>s/<br>/<p>/g</code>
</font>
</p>