Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 10th, 2005, 4:29 PM   #1
yuckz
Newbie
 
Join Date: Sep 2005
Posts: 1
Rep Power: 0 yuckz is on a distinguished road
cgi file upload with images

#!/usr/bin/perl
# location of Perl (above) - check your doc or ask admin

##### SETTABLE VARIABLES ####################################

# URL to go to if there is a problem with form input
$ErrorPage = "http://www.domain.net";

# URL to go to when form has been successfully submitted
$ThankPage = "http://www.domain.net";

# URL to go to if a 'foreign' referer calls the script
$EvilReferer = "http://www.domain.net";

# E-mail address to send incoming form to (your address)
# If not using PERL 5, escape the @ thus: \@ instead of @ 
$YourEmail = 'sales@domain.net';

# Script works only on your server(s) - ('URL1','URL2')
@referers = ('www.domain.net','domain.net');

# Location of mail program - check your doc or ask admin
$MailProgram = '/usr/lib/sendmail';

# Subject of the e-mail autoreply to the submitter
$Subject = "Account set up within the next 24 hours.";

# Brief tail message for body of e-mail autoreply
$Message = "
If you are having any problems please contact a member of our sales and billing staff at http://www.domain.net/contact.htm

Best regards,
www.Domain.net Sales Team";


# Your signature at the end of the autoreply e-mail
$Signature = "www.Domain.net Sales Team";

##### END OF SETTABLE VARIABLES ############################



##### MAIN PROGRAM #########################################
# ___ Do not edit below this line __________________________

&ReadParse;
$Name = $in{'Name'};
$Email = $in{'Email'};
$Amount = $in{'Amount'};
$Payby = $in{'Payby'};
$Date = $in{'Date'};
$Time = $in{'Time'};
&SendSubmission;
&SendAutoReply;
print "Location: $ThankPage\n\n";
exit;

# _________________________________________________________

sub SendSubmission {
open (MAIL,"|$MailProgram -t");
print MAIL "To: $YourEmail\n";
print MAIL "From: $Email\n";
print MAIL "Subject: Process Order\n";
print MAIL "Process Order\n\n";
print MAIL "Name: $Name\n";
print MAIL "Email: $Email\n";
print MAIL "Amount: $Amount\n";
print MAIL "Payby: $Payby\n";
print MAIL "Payment Date: $Date\n";
print MAIL "Payment Time: $Time\n";
close (MAIL);
}

# _________________________________________________________

sub SendAutoReply {
open (MAIL,"|$MailProgram -t");
print MAIL "To: $Email\n";
print MAIL "From: $YourEmail\n";
print MAIL "Subject: $Subject\n";
print MAIL "\n\n";
print MAIL "Dear: $Name\n\n";
print MAIL "You sent the following payment information:\n";
print MAIL "Name: $Name\n";
print MAIL "Email: $Email\n";
print MAIL "Amount: $Amount\n";
print MAIL "Payby: $Payby\n";
print MAIL "Payment Date: $Date\n";
print MAIL "Payment Time: $Time\n\n";
print MAIL "Thank you for your order.We will have your account set up within the next 24 hours, and a confirmation email with username and password will sent to you once the account set up.\n\n";
print MAIL "$Message\n";
close (MAIL);
}

# _________________________________________________________

sub ReadParse { local (*in) = @_ if @_; 
local ($i, $key, $val); if ( $ENV{'REQUEST_METHOD'} eq "GET" ) 
{$in = $ENV{'QUERY_STRING'};} 
elsif ($ENV{'REQUEST_METHOD'} eq "POST") 
{read(STDIN,$in,$ENV{'CONTENT_LENGTH'});} 
else { 
$in = ( grep( !/^-/, @ARGV )) [0];
$in =~ s/\\&/&/g; } @in = split(/&/,$in);
foreach $i (0 .. $#in) { 
$in[$i] =~ s/\+/ /g; 
($key, $val) = split(/=/,$in[$i],2); 
$key =~ s/%(..)/pack("c",hex($1))/ge; 
$val =~ s/%(..)/pack("c",hex($1))/ge; 
$in{$key} .= "\0" if (defined($in{$key})); 
$in{$key} .= $val; } return length($in); }


# _________________________________________________________

exit;

##### End of Script ########################################

how to modified this script so output can include images
thanks in advance
yuckz is offline   Reply With Quote
Old Sep 10th, 2005, 4:51 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
To what extent do you understand what your page does as it stands?
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:05 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC