Hi guys,
I really need your help on that, i’m hitting my head on the walls…and that hurts :crying:
I’m working on an email form contained in a separate .as file coded in AS3 with a php file.
Everything is working just fine when I test it through Flash, having my swf + my .as file locally and my php file online.
As soon as I move all my files online, I submit the form, press my send button, see in the bottom screen of my browser than it seems to be a transfer, but nothing happen, no error message as written in my code…i’m just stuck.
Here is parts of my codes. huge thanks in advance !
Part of my .as file :
private function sendForm():void
{
var variables:URLVariables=new URLVariables();
variables.yourEmail=email_txt.text;
variables.yourMessage=message_txt.text;
variables.yourName=name_txt.text;
var formSender:URLRequest=new URLRequest();
formSender.url='http://www.mywebsite.com/ContactFormSender.php';
formSender.method=URLRequestMethod.POST;
formSender.data=variables;
var loader:URLLoader=new URLLoader();
loader.dataFormat=URLLoaderDataFormat.VARIABLES;
addListeners(loader);
try
{
loader.load(formSender);
}
catch (error:Error)
{
trace('Problem loading the formSender document.');
}
}
private function addListeners(e:IEventDispatcher):void
{
e.addEventListener(Event.OPEN,init);
e.addEventListener(ProgressEvent.PROGRESS,inProgress);
e.addEventListener(Event.COMPLETE,whenFinished);
}
private function init(e:Event):void
{
debug_txt.text='Sending in progress...';
}
private function inProgress(e:ProgressEvent):void
{
debug_txt.text='Sending in progress...';
}
private function whenFinished(e:Event):void
{
var loader:URLLoader=URLLoader(e.target);
var vars:URLVariables=new URLVariables(loader.data);
if(vars.answer=='ok')
debug_txt.text='Your message has been successfully sent';
else
debug_txt.text='An error occurred, please try again';
}
The php sending file
<?php
$to = "mymail@myIsp.com";
$subject = "NEW MESSAGE FROM: XXX";
$message = ($_POST['yourMessage']);
$message .= "
---------------------------
";
$message .= "Email sent from: " . $_POST['yourName'] . " <" . $_POST['yourEmail'] . ">
";
$headers = "From: " . $_POST['yourName'] . " <" . $_POST['yourEmail'] . ">
";
if(@mail($to, $subject, $message, $headers))
{
echo "answer=ok";
}
else
{
echo "answer=error";
}
?>