Link in Zwischenablage kopieren
Kopiert
Hello I am creating a contact form in Flash with AS3 and I am getting this error message:
Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: file:///Macintosh%20HD/Users/animationmanx/Desktop/mail.php
at ContactMovie_fla::MainTimeline/sendMessage()
Here is the code
<?php
$to = "myemailHere.com";
$subject = ($_POST['senderName']);
$message = ($_POST['senderMsg']);
$message .= "\n\n---------------------------\n";
$message .= "E-mail Sent From: " . $_POST['senderName'] . " <" . $_POST['senderEmail'] . ">\n";
$headers = "From: " . $_POST['senderName'] . " <" . $_POST['senderEmail'] . ">\n";
if(@mail($to, $subject, $message, $headers))
{
echo "answer=ok";
}
else
{
echo "answer=error";
}
?>
submit_btn.addEventListener(MouseEvent.CLICK, sendMessage);
function sendMessage(e:MouseEvent):void{
var my_vars:URLVariables = new URLVariables();
my_vars.senderName = name_txt.text;
my_vars.senderEmail = email_txt.text;
my_vars.senderMsg = message_txt.text;
var my_url:URLRequest = new URLRequest("mail.php");
my_url.method = URLRequestMethod.POST;
my_url.data = my_vars;
var my_loader:URLLoader = new URLLoader();
my_loader.dataFormat = URLLoaderDataFormat.VARIABLES;
my_loader.load(my_url);
name_txt.text = "";
email_txt.text = "";
message_txt.text = "Message Sent";
}
I do have my real email in there I just took it out for this post.
you already have that set:
my_loader.dataFormat = URLLoaderDataFormat.VARIABLES;
so you shouldn't see that error message if you're testing the code you posted.
Link in Zwischenablage kopieren
Kopiert
there's no mail.php found in Macintosh%20HD/Users/animationmanx/Desktop/
Link in Zwischenablage kopieren
Kopiert
Ok thanks I fixed that but now it says:
Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
at Error$/throwError()
at flash.net::URLVariables/decode()
at flash.net::URLVariables$iinit()
at flash.net::URLLoader/flash.net:URLLoader::onComplete()
Link in Zwischenablage kopieren
Kopiert
assign your loader's dataFormat property to 'variables'.
Link in Zwischenablage kopieren
Kopiert
Link in Zwischenablage kopieren
Kopiert
you already have that set:
my_loader.dataFormat = URLLoaderDataFormat.VARIABLES;
so you shouldn't see that error message if you're testing the code you posted.
Link in Zwischenablage kopieren
Kopiert
I am still getting this message
Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
at Error$/throwError()
at flash.net::URLVariables/decode()
at flash.net::URLVariables$iinit()
at flash.net::URLLoader/flash.net:URLLoader::onComplete()
Link in Zwischenablage kopieren
Kopiert
then you're not using the code you posted or your local computer doesn't support php.
Link in Zwischenablage kopieren
Kopiert
What should I do?
Link in Zwischenablage kopieren
Kopiert
copy and paste your actionscript into a new fla with those textfields and that button.
publish an html and swf and upload both to a server (that supports php).
copy that php to a text file, name it mail.php and upload to the same directory as your html and swf.
test.
Link in Zwischenablage kopieren
Kopiert
Here is my code:
submit_btn.addEventListener(MouseEvent.CLICK, sendMessage);
function sendMessage(e:MouseEvent):void{
var my_vars:URLVariables = new URLVariables();
my_vars.senderName = name_txt.text;
my_vars.senderEmail = email_txt.text;
my_vars.senderMsg = message_txt.text;
var my_url:URLRequest = new URLRequest("mail.php");
my_url.method = URLRequestMethod.POST;
my_url.data = my_vars;
var my_loader:URLLoader = new URLLoader();
my_loader.dataFormat = URLLoaderDataFormat.VARIABLES;
my_loader.load(my_url);
name_txt.text = "";
email_txt.text = "";
message_txt.text = "Message Sent";
}
Link in Zwischenablage kopieren
Kopiert
i'm not sure what you mean by posting that last message.
again,
copy and paste your actionscript into a new fla with those textfields and that button.
publish an html and swf and upload both to a server (that supports php).
copy that php to a text file, name it mail.php and upload to the same directory as your html and swf.
Link in Zwischenablage kopieren
Kopiert
It seemed to work like you said once I uploaded it to my website server. However, I haven't received the email.
Link in Zwischenablage kopieren
Kopiert
did you remember to change that email address?
Link in Zwischenablage kopieren
Kopiert
Thank you I just saw I didn't change it in the php file.
Link in Zwischenablage kopieren
Kopiert
so, all's well?
Link in Zwischenablage kopieren
Kopiert
Well, I thought so but the email never showed up in my inbox. Here is exactly what I have in the actionscript. And I uploaded the php file too.
this.stop();
<?php
$to = "myemailHERE";
$subject = ($_POST['senderName']);
$message = ($_POST['senderMsg']);
$message .= "\n\n---------------------------\n";
$message .= "E-mail Sent From: " . $_POST['senderName'] . " <" . $_POST['senderEmail'] . ">\n";
$headers = "From: " . $_POST['senderName'] . " <" . $_POST['senderEmail'] . ">\n";
if(@mail($to, $subject, $message, $headers))
{
echo "answer=ok";
}
else
{
echo "answer=error";
}
?>
submit_btn.addEventListener(MouseEvent.CLICK, sendMessage);
function sendMessage(e:MouseEvent):void{
var my_vars:URLVariables = new URLVariables();
my_vars.senderName = name_txt.text;
my_vars.senderEmail = email_txt.text;
my_vars.senderMsg = message_txt.text;
var my_url:URLRequest = new URLRequest("mail.php");
my_url.method = URLRequestMethod.POST;
my_url.data = my_vars;
var my_loader:URLLoader = new URLLoader();
my_loader.dataFormat = URLLoaderDataFormat.VARIABLES;
my_loader.load(my_url);
name_txt.text = "";
email_txt.text = "";
message_txt.text = "Message Sent";
}
Link in Zwischenablage kopieren
Kopiert
you need to change this line:
$to = "myemailHERE";
Link in Zwischenablage kopieren
Kopiert
I have the right email in that spot I just changed it for the purpose of this post. Is it right that I posted the php in the action script panel as well as uploading a separate file to my server?
Link in Zwischenablage kopieren
Kopiert
no php should be in your actionscript. if it is, you should see compiler errors.
the php needs to be in a file named mail.php saved without text formatting (like ms windows would add). ie, use a plain text editor like notepad or wordpad.
Link in Zwischenablage kopieren
Kopiert
I just got it to work completely. That must have been the last problem. That I made the php file using ms word. Thank you for all the help, I really appreciate it!!!
Link in Zwischenablage kopieren
Kopiert
you're welcome.