#!/usr/bin/perl
#- Call the CGI module.
use CGI qw/:standard/ ;
#- Prints errors on the browser
use CGI::Carp qw(fatalsToBrowser);
# Prints to HTML pages..
print header;
# Gets the form feilds out of the forms you made
#- form_feild1 would be one of the form NAMES
$form_feild1 = param('$form_feild1');
$form_feild2 = param('$form_feild2');
$form_feild3 = param('$form_feild3');
$form_feild4 = param('$form_feild4');
$form_feild5 = param('$form_feild5');
# You can do some checks here to see if the information Submitted is valid..... EXAMPLE
if ($form_feild1 eq "") { print "You must enter something in <b>form feild 1</b>"; exit; }
# Get the path to teh DIR you want to save the file in
$my_files_path = "/path/to/where/you/want/file";
# The URl to the file.
$url_to_file = "[URL unfurl="true"]http://www.MySite.com/temp_files";[/URL]
# Generate a Temporay file name
$temp_file_name = time;
# Create the file and write to it
open(FILE, ">$temp_file_path/$temp_file_name\.txt");
# Write to the FILE
print FILE "$form_feild1\n";
print FILE "$form_feild2\n";
print FILE "$form_feild3\n";
print FILE "$form_feild4\n";
print FILE "$form_feild5\n";
print FILE "$form_feild6";
# Close the FILE
close(FILE);
#Mail variables
$to = "me\@me.com";
$reply_to = "who\@who.com";
$from = "My Web Site";
$subject = "THE FORM SUBMISSIONS";
# Teh path to sendmail on your UNIX box
$send_mail = '/usr/lib/sendmail';
# Open SENDMAIL and do some sending...
open (MAIL, "|$send_mail -t");
print MAIL "To: $to\n";
print MAIL "Reply-to: $reply_to <$reply_to>\n";
print MAIL "From: $from <$from>\n";
print MAIL "Subject: $subject\n";
print MAIL "Content-type: text/html\n\n";
# Send the info and / or link
print MAIL "Here is the information submitted from the web site.\n";
print MAIL "Form Feild 1 = $form_feild1\n";
print MAIL "Form Feild 2 = $form_feild2\n";
print MAIL "Form Feild 3 = $form_feild3\n";
print MAIL "Form Feild 4 = $form_feild4 \n";
print MAIL "Form Feild 5 = $form_feild5";
# Sned the URL to the file.
print MAIL "Here is a link to the file made on my web server\n";
print MAIL "<a href=\"$url_to_file/$temp_file_name\.txt\"> THE FILE MADE </a>\n";
# Close The MAIL PROG
close(MAIL);
print "All Done<br>.\n";
print "The file has been created and an email has been sent with a link to the file.\n";
exit;