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";
}
}
?>