PDA

View Full Version : Flash PHP Email Problem



jbkons
November 6th, 2004, 01:43 AM
Hi all,

I am trying to implement a comment form for a flash page using a php email system. I am new to flash, but I got it working for the most part. The problem is that I receive emails, but they are blank and do not contain the info I put in. Below is the Actionscript I used and the php I used. Any help would lbe gret. Thanks!

AS

on (release) {

if (!FirstName.length) {
EmailStatus = "Please Enter your name.";
}

else if (!Email.length || Email.indexOf("@") == -1 || Email.indexOf(".") == -1) {
EmailStatus = "Please enter a valid E-mail";
}
else if (!ToComments.length) {
EmailStatus = "Please enter your message";
}

else {
loadVariablesNum ("MailPHP.php", "0", "Post");
gotoAndPlay(10);
}
}


php code

<?
$ToEmail = "jbb@hotmail.com";
$ToSubject = "Flash contact form";
$EmailBody = "Sent By: $FirstName\nSenders Email: $Email\n\nMessage Sent:\n$ToComments\n";
mail($ToName." <".$ToEmail.">",$ToSubject, $EmailBody, "From: ".$FirstName." <".$Email.">");
?>

ghjr
November 6th, 2004, 09:09 AM
First of all, are you sure the variables are being set in Flash?

To check do this remove or comment the actions on the button and put the following:

on (release) {
trace (FirstName);
trace (Email);
trace (ToComments);
}

Now run the file in flash, fill out your form, and press the send button. A box should pop up with the stuff you typed in. If it does or doesn't, then run back here and tell me. :thumb:

jbkons
November 6th, 2004, 10:44 AM
yep, the box popped up with the information I entered. Does that mean that my variables are set correctly and something else is wrong?

ghjr
November 6th, 2004, 07:34 PM
Yup things in flash seem fine. Okay, now try this for the button actions:



on(press) {
var myVariables = new LoadVars ();
myVariables.firstname = FirstName;
myVariables.email = Email;
myVariables.tocomments = ToComments;
myVariables.send("NAME_OF_YOUR_PHP_FILE.php", "_blank", "POST");
}


And in the PHP file put:



<?php

$name = $_POST['firstname'];
$email = $_POST['email'];
$message = $_POST['tocomments'];

echo $firstname;
echo $email;
echo $tocomments;

?>


Now, fill out your form and press send. It should open up a PHP page with the values of the form. It it doesn't, flash isn't sending the variables correctly.

By the way, maybe you should try your PHP mail function without the extra parameters just to see if it works, like this:



$name = $_POST['firstname'];
$email = $_POST['email'];
$message = $_POST['tocomments'];

$ToEmail = "jbb@hotmail.com";
$ToSubject = "Flash contact form";
$EmailBody = "From: " . $firstname . "Email: " . $email . "Message: " . $message;

mail($ToEmail,$ToSubject, $EmailBody);


Cheers.

wayno
December 22nd, 2004, 09:56 AM
First of all, are you sure the variables are being set in Flash?

To check do this remove or comment the actions on the button and put the following:

on (release) {
trace (FirstName);
trace (Email);
trace (ToComments);
}

Now run the file in flash, fill out your form, and press the send button. A box should pop up with the stuff you typed in. If it does or doesn't, then run back here and tell me. :thumb:

I have to put it like this in order to get data returned from the trace:

trace (form.name);
trace (form.email);

Any ideas why or how to work around this?

Thanks,
Wayne

ghjr
December 22nd, 2004, 10:44 AM
I have to put it like this in order to get data returned from the trace:

trace (form.name);
trace (form.email);

Any ideas why or how to work around this?

Thanks,
Wayne

That looks ok to me wayno... shouldn't be a problem. It works that way because the variables name and email exist in the form moveclip.

Cheers!

wayno
December 22nd, 2004, 10:56 AM
That looks ok to me wayno... shouldn't be a problem. It works that way because the variables name and email exist in the form moveclip.

Cheers! Thanks for the info, but I was still getting blank emails until I used your code for the PHP file. How do I put a from email in there? How do I do a carrage return?


Wayne

ghjr
December 22nd, 2004, 12:49 PM
Wayne,

Try to output the variables in the PHP file to see if it is receiving the info from flash... as suggested here a couple of posts above (http://www.kirupaforum.com/forums/showpost.php?p=668057&postcount=4).

Cheers!