PDA

View Full Version : send data from flash form


armdar
06-03-2009, 05:02 PM
Hello Everyone,

I am trying to send data from my flash form to my server and back to my email.

I've been trying to figure this out and got some help from Paul Ferrie (Super Mod) but I don't want to bother him too much.

Please tell me what I'm doing wrong.

The actions are on the first frame of the form, in a layer called "actions"
stop();
var senderLoad:LoadVars = new LoadVars();
var receiveLoad:LoadVars = new LoadVars();

sender.onRelease = function() {
senderLoad.theName = theName.text;
senderLoad.thePhone = thePhone.text;
senderLoad.theMail = theMail.text;
senderLoad.theBody = theBody.text;
senderLoad.sendAndLoad("http://www.mindovermatter.ca/send.php",receiveLoad,"POST");
};

receiveLoad.onLoad = function() {
if (this.sentOk) {
gotoAndStop("success");
} else {
gotoAndStop("failed");
}
};

<?PHP

$to = "[email protected]";
$subject = "Msg from MindOverMatter.ca";
$message = "Name: " . $theName;
$message .= "\nPhone Number: " . $thePhone;
$message .= "\n\nEmail: " . $theMail;
$message .= "\n\n\nMessage: " . $theBody;
$headers ="From: $theMail\n" . "Reply-To: $theMail" . "X-Mailer: PHP/" . phpversion();


$sentOK = mail($to,$subject,$message,$headers);

echo "sentOK=" . $sentOK;

?>What I did next:

Published .fla to html. Uploaded index.html to my public_http directory on my server, along with: AC_RunActiveContent.js, flash.swf, send.php

So all of these files are contained in the public_html directory

When I go to fill out the info and test the form, I am brought to the "sorry failed" frame... which is good and bad. It's good I'm being told it did not work, it's bad because it isn't working.

I have tested my email configurations to verify that I set it up properly and I am receiving email, so that isn't the problem.

any trouble shooting and outside input to help solve this problem is hugely appreciated

Here is a link to my .fla (http://rapidshare.com/files/240478345/flash_1_.zip.html) - please any feedback would be helpful!!


THANK YOU!

Cota
06-03-2009, 11:47 PM
So the problem seems to be the mail isnt sending. I would suggest looking into the headers. Some servers get very picky when it comes to the headers.

armdar
06-04-2009, 12:44 AM
OK Cota I am going to be totally honest with you

but first: THANK YOU for replying. I really want to get this to work.


but I'm pretty new and still getting over the learning curve. I wasn't sure about what you meant by headers, so I did a search and pulled up some info about my server's headers. Here is what it came back with:

#1 Server Response: http://mindovermatter.ca
HTTP Status Code: HTTP/1.1 200 OK
Date: Thu, 04 Jun 2009 00:34:25 GMT
Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8i DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
Last-Modified: Tue, 02 Jun 2009 18:09:09 GMT
ETag: "11520060-ab9-46b61706c7b40"
Accept-Ranges: bytes
Content-Length: 2745
Connection: close
Content-Type: text/html

I wanted to get some more info on how these headers reflect on flash, so I came across this: http://kb2.adobe.com/cps/403/kb403185.html

What I gather is I have to create an .xml file so my domain can accept headers from a remote .swf

There are a few examples on the adobe site... which would you recommend for my project?

All I will have to do is make up the .xml in dreamweaver and upload to my public_html?

This is not something I would have guessed on my own as this is my first flash website undertaking so your input has proven very insightful. Thank you again for helping this beginner!!

Cota
06-04-2009, 02:02 AM
if the swf and php are on the same server then you wont need any of that. The headers I was referring to were in the PHP. Try this one

<?PHP

$to = "[email protected]";
$subject = "Msg from MindOverMatter.ca";
$message = "Name: " . $theName;
$message .= "\nPhone Number: " . $thePhone;
$message .= "\n\nEmail: " . $theMail;
$message .= "\n\n\nMessage: " . $theBody;

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '.$theMail."\r\n";

$sentOK = mail($to,$subject,$message,$headers);

echo "sentOK=" . $sentOK;

?>

armdar
06-04-2009, 04:25 AM
Oooh!

...heh heh. see how new i am?

hmm, but I will say I uploaded your .php and still no success. =( I am beginning to believe I am cursed!

Should I contact my hosting service to find out about php headers for my server?

sry I know you are busy!! thank you for your time and input it really means a lot to me :)

Cota
06-04-2009, 02:08 PM
You could also try to send it without any headers. Contacting them is always a good idea. They will be able to tell you exactly what their mail server will and wont take.

armdar
06-04-2009, 03:38 PM
Alright! I just got off the phone with HostGator and they sent me to this example: http://email.about.com/od/emailprogrammingtips/qt/et073006.htm and I was instructed to use the SMTP Authentication code (they said it is guarenteed to work on their server).

As below:
<?php
require_once "Mail.php";

$from = "Sandra Sender <[email protected]>";
$to = "Ramona Recipient <[email protected]>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "mail.example.com";
$username = "smtp_username";
$password = "smtp_password";

$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>

So I just need to customize it and save as send.php, upload to public_html directory? Or should I upload this to my mail directory?

I left the passwords unfilled. Does this look right? Also how can I concatinate the phone number onto this string as well?

<?php
require_once "Mail.php";

$from = "From: " . $theMail;
$to = "Mind Over Matter <[email protected]>";
$subject = "Msg from MindOverMatter.ca";
$body = "Msg: " . theBody;


$host = "mail.mindovermatter.ca";
$username = "smtp_armdar";
$password = "smtp_password";

$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $armdar,
'password' => $password);

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>


Sorry I am still learning!

THANK YOU AGAIN FOR ALL OF YOUR TIME AND HELP!

Cota
06-05-2009, 03:15 AM
from what I see looks like you just need to change this line

$from = "From: " . $theMail;


to


$from = $theMail;

armdar
06-06-2009, 05:11 PM
Excellent, I will give that a shot.

I am just out of town right now and do not have access to my project.

A concern I do have is with this line:

echo("<p>Message successfully sent!</p>");

In my .fla, the failed/success frames are named just as that; "failed", "succes"
Do I need to change this line?


Thank you again Cota for looking at this. Like I said, this is my first flash website and I would have never figured this out on my own. I'm really thankful for these forums and the help of you lovely Mods. =)

Cota
06-08-2009, 02:27 AM
Ah yes. Change that line. Make sure you echo it out in variable format.