473,383 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Email submition forms?

1
I have built a series of email forms in flash MX. using perl. the forms work for some people but not all and I was hoping some one could help me out.

Here is the Actionscript on the send button

on (release, keyPress "<Enter>") {
if (company ne "" and first ne "" and last ne "" and phone ne "" and fax ne "" and mobile ne "" and email ne "" and address ne "" and city ne "" and state ne "" and zip ne "") {
i = "0";
validmail = 0;
while (Number(i)<=Number(length(email))) {
if (substring(email, i, 1) eq "@") {
validmail = 1;
}
i = Number(i)+1;
}
// If there's no @ in the email go to the error page.
if (Number(validmail) == 0) {
status = "User Input Error";
} else {
loadVariablesNum("http://bostongreenrealty.com/cgi/email.cgi", 0, "POST");
status = "Thank you for signing up";
play();
}
} else {
// if the user left required fields blank, show them an error message.
status = "User Input Error";
}
}

and here is the perl script

#!/usr/bin/perl


$SENDMAIL = '/usr/sbin/sendmail';

@AUTHURLS = ('www.bostongreenrealty.com','bostongreenrealty.co m');

$TO = 'bostongreenrealty@gmail.com';

$SUBJECT = 'Mailing List';

$SORT_TYPE = 'none';

@SORT_FIELDS = ('Field1','Field2','Field3','Field4','Field5');

################################################## ##########################

# Check to make sure this script was called by an authorized URL(s)

&check_url;

# Format Local Date/Time for Email Message Date

&get_date;

# Reformat Form Contents

&reformat_form_data;

# Send the form data to the recipient via e-mail

&send_email;


exit();

################################################## ##############

sub check_url
{
if ($ENV{'HTTP_REFERER'})
{
foreach $AUTHURL (@AUTHURLS)
{
if ($ENV{'HTTP_REFERER'} =~ /$AUTHURL/i)
{
$check_url = '1';
last;
}
}
}
else
{
$check_url = '1';
}

if ($check_url != 1)
{
print "Content-type: text/html\n\n";
print "<html>\n <head>\n <title>Unauthorized URL Referrer - Access Denied</title>\n </head>\n";
print " <body>\n <center>\n <h1>Unauthorized URL Referrer - Access Denied</h1>\n </center>\n";
print "The form that is trying to use this script resides at: \n";
print "$ENV{'HTTP_REFERER'}, which is not allowed to access this cgi script.<p>\n";
print "Sorry!\n";
print "</body></html>\n";
exit;
}

}

sub get_date
{
@days = ('Sunday','Monday','Tuesday','Wednesday','Thursday ','Friday','Saturday');
@months = ('January','February','March','April','May','June' ,'July',
'August','September','October','November','Decembe r');

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isd st) = localtime(time);
if ($hour < 10)
{ $hour = "0$hour"; }
if ($min < 10)
{ $min = "0$min"; }
if ($sec < 10)
{ $sec = "0$sec"; }
if ($year < 10)
{ $year = "0$year"; }
if ($year < 90)
{ $cent = "20"; }
else
{ $cent = "19"; }

$date = "$days[$wday], $months[$mon] $mday, $cent$year at $hour\:$min\:$sec";

$mon = $mon + 1;
if ($mon < 10)
{ $mon = "0$mon"; }
if ($mday < 10)
{ $mday = "0$mday"; }

$dateShort = "$cent$year\-$mon\-$mday";
$timeShort = "$hour\:$min\:$sec";

}

sub reformat_form_data
{
if ($ENV{'REQUEST_METHOD'} eq 'POST')
{
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
}
else
{
print "Content-type: text/html\n\n";
print "<html>\n <head>\n <title>Error: Request Method</title>\n </head>\n";
print "<body>\n <center>\n\n <h1>Error: Request Method</h1>\n </center>\n\n";
print "The Request Method of the Form you submitted was not\n";
print "POST. Please check the form, and make sure the\n";
print "method= statement is in upper case and is set to POST.\n";
print "<p><hr size=7 width=75%><p>\n";
print "<ul>\n";
print "<li><a href=\"$ENV{'HTTP_REFERER'}\">Back to the Submission Form</a>\n";
print "</ul>\n";
print "</body></html>\n";
exit;
}
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
if ($name eq 'email' || $name eq 'Name' && ($value))
{
$CONFIG{$name} = $value;
}
if ($name eq 'to_email' && ($value))
{
$TO = $value;
}
elsif ($name eq 'subject' && ($value))
{
$SUBJECT = $value;
}
elsif ($name eq 'redirect' && ($value))
{
$REDIRECT = $value;
}
elsif ($name eq 'sort_type' && ($value))
{
$SORT_TYPE = $value;
}
elsif ($name eq 'sort_fields' && ($value))
{
@SORT_FIELDS = split(/,/, $value);
}
elsif ($FORM{$name} && ($value))
{
$FORM{$name} = "$FORM{$name}, $value";
}
elsif ($value)
{
$FORM{$name} = $value;
}
}
}

sub send_email
{
# Build the 'from' address of the form: "name <email address>"

$from_name=($CONFIG{'Name'} . " <" . $CONFIG{'email'} . "> ");

open(MAIL,"|$SENDMAIL -t") || die "Can't open $mailprog!\n";

# Output the mail header

print MAIL "To: $TO\r\n";
print MAIL "From: $from_name\r\n";
print MAIL "Reply-To: $from_name\r\n";
print MAIL "Subject: $SUBJECT\r\n\n";

# Output the mail message header with the Local Date/Time

print MAIL "---------------------------------------------------------------\n\n";
print MAIL " The following information was submitted by: \n";
print MAIL " $CONFIG{'Name'} on $date\n\n";
print MAIL "---------------------------------------------------------------\n\n";

# Output the mail body
# Optionally Sort and Print the name and value pairs in FORM array

if ($SORT_TYPE eq 'alphabetic')
{
foreach $key (sort keys %FORM)
{
print MAIL "$key: $FORM{$key}\n\n";
}
}
elsif ($SORT_TYPE eq 'field')
{
foreach $SORT_FIELD (@SORT_FIELDS)
{
if ($FORM{$SORT_FIELD})
{
print MAIL "$SORT_FIELD: $FORM{$SORT_FIELD}\n\n";
}
}
}
else
{
foreach $key (keys %FORM)
{
print MAIL "$key: $FORM{$key}\n\n";
}
}

# Output the mail footer

print MAIL "<REMOTE HOST> $ENV{'REMOTE_HOST'}\n";
print MAIL "<REMOTE ADDRESS> $ENV{'REMOTE_ADDR'}\n";
print MAIL "<USER AGENT> $ENV{'HTTP_USER_AGENT'}\r\n";

# Close the pipe and send the mail

close(MAIL);
}

Thanks
Grevo.
Aug 2 '08 #1
0 2022

Sign in to post your reply or Sign up for a free account.

Similar topics

88
by: Mike | last post by:
Is there a way to determine what a user's default email client is? I read a post from 3 years ago that said no. I guess I'm hoping something has come along since then.
1
by: Keith | last post by:
I'm sending a email via Access 2000 and don't have a problem with the basic format. What I want it to automatically grab the email of the tech and insert it in the TO. I have a combo box which...
4
by: acni | last post by:
I have the following peice of code to try and send an email to selected contacts in my form.The problem is this line: StrStore = DLookup("", "qrySelectEmail", "??????") This looks up the email...
0
by: Jitu | last post by:
<form runat=server id=myform> <AT_COMMON:SitePage id="DefaultPage" runAt="Server"> <itemTemplate> <AT:UsersRegistration id="Registration" RunAt="Server" UserFormName="Users/Users/UserForm.ascx"...
3
by: Siv | last post by:
Hi, A little while ago I wrote a small program that allowed the user to view products from a database. The database holds the details of the products which can be viewed via a form and...
36
by: Liam.M | last post by:
hey guys, I have one last problem to fix, and then my database is essentially done...I would therefore very much appreciate any assistance anyone would be able to provide me with. Currently I...
1
by: sahay | last post by:
Retain a visitor-specified value in a select option after page submition
0
by: Sister Ray | last post by:
I'm trying to create a simple form that sends an email using my company's exchange server. I'm using the System.Net.Mail Namespace of the .net framework 2.0. I've googled everywhere and i think my...
4
by: Tony M | last post by:
VS 2005 - XP media - VB .net - winforms - .net 2.0 Just trying to send an email, here is the code and the error message that I get. I can't figure out how to fix it?
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.