I have been working on a website using Flash and I decided to add a contact form. I downloaded the php file online and I put the file in the same folder as my fla file. When I tested my fla file, everything worked fine and after you click send, it goes to the right page on the website.
I then transfered the folder to my web hosting site using FileZilla. After the files were dragged in, I tested it and for some reason, the contact form doesn't work. It says waiting for www.iantopple.com..... Since this is also a fake website the only way to access it is through my own website.
I'm really not sure what I'm doing wrong. I'm assuming it's a path issue but I tested the fla file and it does work when I test it. Does anyone know what I'm doing wrong? Is there a different way to upload a php file online? Pasted below is my AS3 and my PHP code. You can view the website here:
www.iantopple.com/SimmiSampleSite.swf
Here is my actionscript code:
stop();
var validmail:uint = 0;
var variables:URLVariables = new URLVariables();
var varSend:URLRequest = new URLRequest("sendEmailIan.php");
var varLoader:URLLoader = new URLLoader;
varSend.method = URLRequestMethod.POST;
varSend.data = variables;
submit_btn.addEventListener (MouseEvent.CLICK, sendActions);
varLoader.addEventListener (Event.COMPLETE, loadComplete);
function sendActions (event:MouseEvent):void
{
if ((fname_txt.text != "" || subject_txt.text != "Required")
&& email_txt.text != "" && (subject_txt.text != "" || subject_txt.text != "Required") ) {
// Check to make sure the email address includes and @.
var textLength:Number = email_txt.text.length;
for (var i:Number = 0; i < textLength; i++) {
if (email_txt.text.substr(i, 1) == "@") {
this.validmail = 1;
break;
}
}
}
if (this.validmail == 0) {
this.gotoAndStop ("error");
} else {
variables.key = "pass";
variables.subject = subject_txt.text;
variables.fname = fname_txt.text;
variables.email = email_txt.text;
variables.comments = comments_txt.text;
varLoader.load (varSend);
}
}
function loadComplete (event:Event)
{
var loader:URLLoader = URLLoader(event.target);
trace ("completeHandler: " + loader.data);
//loader.dataFormat = URLLoaderDataFormat.VARIABLES;
//trace(event.target.data);
//var vars:URLVariables = new URLVariables(loader.data);
//trace ("The reply was " + vars.reply);
if (loader.data != "&reply=error") {
//if (vars.reply != "error") {
this.gotoAndStop ("success");
} else {
this.gotoAndStop ("error");
}
}
fname_txt.tabIndex = 2;
subject_txt.tabIndex = 3;
email_txt.tabIndex = 4;
comments_txt.tabIndex = 5;
submit_btn.tabIndex = 6;
this.stop ();
Here is my php code:
<?
if(isset($_POST['fname'])){$fname = stripslashes($_POST['fname']);}
else {$error .= "Your Name seems to be missing!";}
if(isset($_POST['subject'])){$subject = stripslashes($_POST['subject']);}
else {$error .= "your subject seems to be missing!";}
if(isset($_POST['email'])){$email = stripslashes($_POST['email']);}
else {$error .= "your email seems to be missing!";}
if(isset($_POST['comments'])){$comments = stripslashes($_POST['comments']);}
else {$error .= "The comments of your email seems to be missing!";}
if ($_POST['key'] == "pass") {
$to = "example@example.com";
$subject = "{$_POST['subject']}";
$message = "Sent From http://www.IanTopple.com/SimmiSampleSite.swf"
";
if ($_POST['comments'] != "") {
$message .= "
{$_POST['fname']} had the following comments:
{$_POST['comments']}
";
}
$headers = "";
$headers .= "From: " . $_POST['fname'] . " <" . $_POST['email'] . ">\n";
$headers .= "Reply-To: " . $_POST['fname'] . " <" . $_POST['email'] . ">\n";
$headers .= "X-Mailer: PHP4\n" ; // mailer
$headers .= "X-Priority: 3\n" ; // priority
$headers .= "Return-Path: $to\n";
$headers .= "Origin: ".$_SERVER['REMOTE_ADDR']."\n";
$headers .= "Content-Type: text/plain; charset=us-ascii\n";
if (mail($to,$subject,$message,$headers)) {
echo "&reply=success";
} else {
echo "&reply=error";
}
?>