473,767 Members | 7,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Email submition forms?

1 New Member
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)<=Num ber(length(emai l))) {
if (substring(emai l, i, 1) eq "@") {
validmail = 1;
}
i = Number(i)+1;
}
// If there's no @ in the email go to the error page.
if (Number(validma il) == 0) {
status = "User Input Error";
} else {
loadVariablesNu m("http://bostongreenreal ty.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.bostongre enrealty.com',' bostongreenreal ty.com');

$TO = 'bostongreenrea lty@gmail.com';

$SUBJECT = 'Mailing List';

$SORT_TYPE = 'none';

@SORT_FIELDS = ('Field1','Fiel d2','Field3','F ield4','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_REF ERER'})
{
foreach $AUTHURL (@AUTHURLS)
{
if ($ENV{'HTTP_REF ERER'} =~ /$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>Unauthor ized URL Referrer - Access Denied</title>\n </head>\n";
print " <body>\n <center>\n <h1>Unauthorize d URL Referrer - Access Denied</h1>\n </center>\n";
print "The form that is trying to use this script resides at: \n";
print "$ENV{'HTTP_REF ERER'}, which is not allowed to access this cgi script.<p>\n";
print "Sorry!\n";
print "</body></html>\n";
exit;
}

}

sub get_date
{
@days = ('Sunday','Mond ay','Tuesday',' Wednesday','Thu rsday','Friday' ,'Saturday');
@months = ('January','Feb ruary','March', 'April','May',' June','July',
'August','Septe mber','October' ,'November','De cember');

($sec,$min,$hou r,$mday,$mon,$y ear,$wday,$yday ,$isdst) = 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\:$s ec";

$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_d ata
{
if ($ENV{'REQUEST_ METHOD'} eq 'POST')
{
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_L ENGTH'});
# 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{'HT TP_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{$nam e}, $value";
}
elsif ($value)
{
$FORM{$name} = $value;
}
}
}

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

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

open(MAIL,"|$SE NDMAIL -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_FI ELD})
{
print MAIL "$SORT_FIEL D: $FORM{$SORT_FIE LD}\n\n";
}
}
}
else
{
foreach $key (keys %FORM)
{
print MAIL "$key: $FORM{$key}\n\n ";
}
}

# Output the mail footer

print MAIL "<REMOTE HOST> $ENV{'REMOTE_HO ST'}\n";
print MAIL "<REMOTE ADDRESS> $ENV{'REMOTE_AD DR'}\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 2035

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

Similar topics

88
12549
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
1683
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 lists the techs name and in a seperate field has the email addresses. I also have a separate table which contains just the emails. Any suggestions? This is the code I'm using.
4
2808
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 field in the records returned for the query qrySelectEmail. The final bit needs to tell it to go to the first record the first time the loop runs, then the second record the second time the loop runs etc… But I cannot figure out a way to do this,...
0
1047
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" SkinFileName="Users/Users/UserRegistration.ascx" /> </itemTemplate> </AT_COMMON:SitePage> </form>
3
2855
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 additionally pictures of the product are stored in an images subfolder and the database holds the file name of the relevant picture. The user can then click a button to display the picture in a pop-up window and also another button to email the potential...
36
3072
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 have set up a Query to show only records that meet a certain criteria...therefore excluding all of the records that do not meet this criteria (just for the record the criteria is any record within my database that falls within two months of its "Due...
1
1411
by: sahay | last post by:
Retain a visitor-specified value in a select option after page submition
0
2776
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 code is ok, however i keep getting a "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond" error every time. Any...
4
4261
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
9575
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9407
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10014
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9841
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8840
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5280
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5425
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3534
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2808
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.