Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 02-25-2011, 05:33 PM   #1
s22225
Registered User
 
Join Date: Feb 2011
Posts: 5
Unhappy Flash/PHP Email Form Issues

I have been struggling with this Flash/PHP Email Form for weeks from a template I have been using. Everything seems to be good with the PHP file and location on the server, but not sure about the Actionscript. I assume it has something to do with this portion of the code (full code below):
btnSubmit.onRelease = function ()
{
if (txtField1.text == label1 || txtField2.text == label2 || txtField3.text == label3)
{
gotoAndStop(3);
}
else
{
_parent.contactform.loadVariables("email.php", "POST");
gotoAndStop(2);
} // end else if
};
stop ();
Any helpful hints and such would be really appreciated. I’ve been searching for answers and posting on forums and yet to get a good solution.

Thanks.


Here is the full Flash Actionscript code that doesn't seem to be sending the data to the PHP file to email out. When the user submits the form on the website, no errors are generated at all. The PHP file is located at the same level in the website directory structure.


function clearField()
{
txtField1.text = label1;
txtField2.text = label2;
txtField3.text = label3;
Selection.setFocus("_focus");
} // End of the function
label1 = "NAME:";
label2 = "E-MAIL:";
label3 = "MESSAGE:";
var mcContacform = _root.contactform;
countField = 5;
clearField();
var arrayLabel = new Array();
for (i = 1; i < countField + 1; i++)
{
txtField = this["txtField" + i];
txtField.index = i;
arrayLabel[i] = this["label" + i];
txtField.tabIndex = i;
txtField.onSetFocus = function ()
{
if (this.text == arrayLabel[this.index])
{
this.text = "";
} // end if
};
txtField.onKillFocus = function ()
{
if (this.text == "")
{
this.text = arrayLabel[this.index];
} // end if
};
} // end of for
btnClear.onRollOver = function ()
{
this.gotoAndPlay("over");
};
btnClear.onRollOut = btnClear.onReleaseOutside = function ()
{
this.gotoAndPlay("out");
};
btnClear.onRelease = function ()
{
clearField();
};
btnSubmit.onRollOver = function ()
{
this.gotoAndPlay("over");
};
btnSubmit.onRollOut = btnSubmit.onReleaseOutside = function ()
{
this.gotoAndPlay("out");
};
btnSubmit.onRelease = function ()
{
if (txtField1.text == label1 || txtField2.text == label2 || txtField3.text == label3)
{
gotoAndStop(3);
}
else
{
_parent.contactform.loadVariables("email.php", "POST");
gotoAndStop(2);
} // end else if
};
stop ();



Here is the PHP with my email and site name to be coded:


<?php
//Type the receiever's e-mail address
$emailAddress = "my@emailaddress";
//Type your Site Name
$siteName = "My Site";

$contact_name = $_POST['name'];
$contact_email = $_POST['email'];
$contact_message = $_POST['message'];

if( $contact_name == true ) {
$sender = $contact_email;
$receiver = $emailAddress;
$client_ip = $_SERVER['REMOTE_ADDR'];

$email_body = "The Name Of The Sender: $contact_name \nEmail: $sender
\n\nMessage: \n\n$contact_message \n\nIP ADDRESS: $client_ip \n\n$siteName";

$emailAutoReply = "Hi $contact_name, \n\nWe have just received your E-Mail. We will get
in touch in a few days. Thank you! \n\n$siteName ";

$extra = "From: $sender\r\n" . "Reply-To: $sender \r\n" . "X-Mailer: PHP/" . phpversion();
$autoReply = "From: $receiver\r\n" . "Reply-To: $receiver \r\n" . "X-Mailer: PHP/" . phpversion();

mail( $sender, "Auto Reply: $contact_name", $emailAutoReply, $autoReply );

if( mail( $receiver, "New E-Mail - $contact_name", $email_body, $extra ) ) {
echo "success=yes";
} else {
echo "success=no";
}
}
?>
s22225 is offline   Reply With Quote
Old 02-26-2011, 03:31 AM   #2
mike007
Member
 
Join Date: Feb 2011
Posts: 50
Default

Have you tried the php email script by it's self to see if that part works first?

Quote:
Originally Posted by s22225 View Post
I have been struggling with this Flash/PHP Email Form for weeks from a template I have been using. Everything seems to be good with the PHP file and location on the server, but not sure about the Actionscript. I assume it has something to do with this portion of the code (full code below):
btnSubmit.onRelease = function ()
{
if (txtField1.text == label1 || txtField2.text == label2 || txtField3.text == label3)
{
gotoAndStop(3);
}
else
{
_parent.contactform.loadVariables("email.php", "POST");
gotoAndStop(2);
} // end else if
};
stop ();
Any helpful hints and such would be really appreciated. I’ve been searching for answers and posting on forums and yet to get a good solution.

Thanks.


Here is the full Flash Actionscript code that doesn't seem to be sending the data to the PHP file to email out. When the user submits the form on the website, no errors are generated at all. The PHP file is located at the same level in the website directory structure.


function clearField()
{
txtField1.text = label1;
txtField2.text = label2;
txtField3.text = label3;
Selection.setFocus("_focus");
} // End of the function
label1 = "NAME:";
label2 = "E-MAIL:";
label3 = "MESSAGE:";
var mcContacform = _root.contactform;
countField = 5;
clearField();
var arrayLabel = new Array();
for (i = 1; i < countField + 1; i++)
{
txtField = this["txtField" + i];
txtField.index = i;
arrayLabel[i] = this["label" + i];
txtField.tabIndex = i;
txtField.onSetFocus = function ()
{
if (this.text == arrayLabel[this.index])
{
this.text = "";
} // end if
};
txtField.onKillFocus = function ()
{
if (this.text == "")
{
this.text = arrayLabel[this.index];
} // end if
};
} // end of for
btnClear.onRollOver = function ()
{
this.gotoAndPlay("over");
};
btnClear.onRollOut = btnClear.onReleaseOutside = function ()
{
this.gotoAndPlay("out");
};
btnClear.onRelease = function ()
{
clearField();
};
btnSubmit.onRollOver = function ()
{
this.gotoAndPlay("over");
};
btnSubmit.onRollOut = btnSubmit.onReleaseOutside = function ()
{
this.gotoAndPlay("out");
};
btnSubmit.onRelease = function ()
{
if (txtField1.text == label1 || txtField2.text == label2 || txtField3.text == label3)
{
gotoAndStop(3);
}
else
{
_parent.contactform.loadVariables("email.php", "POST");
gotoAndStop(2);
} // end else if
};
stop ();



Here is the PHP with my email and site name to be coded:


<?php
//Type the receiever's e-mail address
$emailAddress = "my@emailaddress";
//Type your Site Name
$siteName = "My Site";

$contact_name = $_POST['name'];
$contact_email = $_POST['email'];
$contact_message = $_POST['message'];

if( $contact_name == true ) {
$sender = $contact_email;
$receiver = $emailAddress;
$client_ip = $_SERVER['REMOTE_ADDR'];

$email_body = "The Name Of The Sender: $contact_name \nEmail: $sender
\n\nMessage: \n\n$contact_message \n\nIP ADDRESS: $client_ip \n\n$siteName";

$emailAutoReply = "Hi $contact_name, \n\nWe have just received your E-Mail. We will get
in touch in a few days. Thank you! \n\n$siteName ";

$extra = "From: $sender\r\n" . "Reply-To: $sender \r\n" . "X-Mailer: PHP/" . phpversion();
$autoReply = "From: $receiver\r\n" . "Reply-To: $receiver \r\n" . "X-Mailer: PHP/" . phpversion();

mail( $sender, "Auto Reply: $contact_name", $emailAutoReply, $autoReply );

if( mail( $receiver, "New E-Mail - $contact_name", $email_body, $extra ) ) {
echo "success=yes";
} else {
echo "success=no";
}
}
?>
mike007 is offline   Reply With Quote
Old 02-26-2011, 03:36 AM   #3
s22225
Registered User
 
Join Date: Feb 2011
Posts: 5
Default

I'm a newbie to scripting and php..when i load the .php file on the server it's a blank page. Is there an easy way to test this?

Thanks.
s22225 is offline   Reply With Quote
Old 02-26-2011, 04:08 AM   #4
mike007
Member
 
Join Date: Feb 2011
Posts: 50
Default

Quote:
Originally Posted by s22225 View Post
I'm a newbie to scripting and php..when i load the .php file on the server it's a blank page. Is there an easy way to test this?

Thanks.
How are you running it? On a webserver? online or home server?
mike007 is offline   Reply With Quote
Old 02-26-2011, 05:32 AM   #5
s22225
Registered User
 
Join Date: Feb 2011
Posts: 5
Default

I'm running it on a web server using a hosting package with Hostgator. I have run other PHP mail scripts without a problem in the past..not using Flash though.
s22225 is offline   Reply With Quote
Old 02-26-2011, 11:28 PM   #6
mike007
Member
 
Join Date: Feb 2011
Posts: 50
Default

But does this one work with out the flash part?
Is this in Flash or Flex. Because I see that you have some If statements in PHP. I usually do all the validation in the client app and they just have a key sent to the php to verify that the request is authentic.

Quote:
Originally Posted by s22225 View Post
I'm running it on a web server using a hosting package with Hostgator. I have run other PHP mail scripts without a problem in the past..not using Flash though.

Last edited by mike007; 02-26-2011 at 11:35 PM.
mike007 is offline   Reply With Quote
Old 02-27-2011, 12:43 AM   #7
s22225
Registered User
 
Join Date: Feb 2011
Posts: 5
Default

This is a flash script but I'm unsure how to test these components independently..
s22225 is offline   Reply With Quote
Old 02-27-2011, 01:04 AM   #8
mike007
Member
 
Join Date: Feb 2011
Posts: 50
Default

Here is my php email script:
Code:
function sendEmail($toaddress)
{
$to = $toaddress;
$subject = "Subject goes here";
$body = "Body of the email";
$from = "This is your email that you are sending from";
$headers = "From: $from";

	 if (mail($to, $subject, $body, $headers)) 
	 {
  		return "1";
 	 } 
 	else 
 	 {
 		return "0";
 	 }
}
This is simple and works.
mike007 is offline   Reply With Quote
Old 02-27-2011, 02:02 AM   #9
s22225
Registered User
 
Join Date: Feb 2011
Posts: 5
Default

so i should replace my php script with that code to see if it works? any chance you can IM or talk voice on gchat or msn?
s22225 is offline   Reply With Quote
Old 02-27-2011, 04:35 PM   #10
mike007
Member
 
Join Date: Feb 2011
Posts: 50
Default

I just want to make sure that it is not a problem with your PHP code before we start to troubleshoot the flash part. I sent you a PM with my gtalk.

Quote:
Originally Posted by s22225 View Post
so i should replace my php script with that code to see if it works? any chance you can IM or talk voice on gchat or msn?
mike007 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:27 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.