FMX - php mail form problem

Hi,
I’ve already searched to see if I could find a solution, but wasn’t able to come up with anything that has helped. So, here’s the problem I am having.
I followed this tutorial for a php mail form in flash:
http://www.flashadvisor.com/tutorial/beginners/custom_php_email_form.php
(and now its offline…geez, great timing…)
Here is the mailform.php:


<?php 
$TextVariable = '&results='; 
$response = 'Thank you. Your email has been sent.'; 
echo $TextVariable; 
echo $response; 
/* recipients */ 
$recipient .= "info@interaptive.com" ; 
/* subject */ 
$subject = "Interaptive site mail"; 
/* message */ 
$message .= "Name: $name 
Email: $email 

Comments: $comments
"; 
/* additional header pieces for errors, From cc's, bcc's, etc */ 
$headers .= "From: $name <$email>
"; 


/* and now mail it */ 
mail($recipient, $subject, $message, $headers); 
?> 

I know that ‘something’ is working, because i get sent emails, but they are blank, except for the headings.(Name:, email:, comments:,) Im a php noob, but obviously there is a problem getting the variables passed from the flash form to the php - and on to the email.
Here is the AS on my send button:
[AS]
on(release){
if (!_root.contents.email.length || _root.contents.email.indexOf("@") == -1 || _root.contents.email.indexOf(".") == -1) {
_root.contents.results = “Please check your email address.”;
} else if (!_root.contents.comments.length) {
_root.contents.results = “Please enter a message.”;
} else if (!_root.contents.name.length) {
_root.contents.results = “Please enter your name.”;
} else {
loadVariables(“http://www.interaptive.com/mailform.php”, “_root.contents”, “GET”);
_root.contents.results = “: : Transmitting : :”;
}
}

[/AS]
I have 3 input textfields, with var names of name, email, comments respectively, as well as a dynamic field with a var name of results.

Does anybody have advice or suggestions as to how to fix this? Please help me out, I’m spinning my tires here=] Thanks, much appreciated!!
cheers
drew

did you try using “POST” instead of “GET”???

otherwise post your .fla and i’ll try to take a look at it.

I just tried “POST” but the exact same problem occurs with the blank headings.
I’ve zipped up contact.fla, please have a look =]
Thanks very much for your help!

Hey dude, here is a much more simple PHP mail form I use all the time, just change what you need:


<?
$toEmail = "aknatn411@comcast.net";

$subject = "Response from decisionhome.com";

$emailBody = "Sent By: $name
Senders Email: $email


Message Sent:
$comments

";

$EmailFooter="
This message was sent by: $name from $REMOTE_ADDR If you feel that you recieved this e-mail by accident please contact us at www.smorgyporf.com";

$Message = $emailBody.$EmailFooter;

mail($toEamil." <".$toEmail.">",$subject, $Message, "From: ".$name." <".$email.">");


Print "_root.EmailStatus=Send complete, your message has been sent to Decision Home of Fresno";

?>

Here is the AS (attach it to your send button):


on (release) {
 if (!email.length || email.indexOf("@") == -1 || email.indexOf(".") == -1) {
 EmailStatus = "Please enter a valid E-mail address";
 }
 else if (!name.length) {
 EmailStatus = "Please enter your name";
 }
 else if (!comments.length) {
 EmailStatus = "Please fill the comments area";
 }
 else {
 loadVariablesNum ("mail.php", "0", "Post");
 EmailStatus = "Your message is being sent............";
 }
}

Cheers, they look quite similar on the AS side of things, so it should be an easy fix.
Thanks very much=]

I’m still having issues with this; I’ve adapted aknatn’s AS n php above, changed my var names on the textfields, and the variables just aren’t getting through. I think it must be a pathing problem? LoadVarialbesNum uses levels; so it sends all vars on _level0 … but this contact page is a nested clip in a root mc, so _root.contents . Is that still level 0? I’ve uploaded the new mail.php to my server, so it should be working even from previewing locally. (ive used an absolute URL in the loadVariablesNum) but now i get nothing, no mail sent at all.

When i list my variables in my output window, the variables are seen: (the crap i typed in…)
Variable _level0.contents.name = "xc"
Variable _level0.contents.email = "s@w.c"
Variable _level0.contents.comments = "as"
Variable _level0.contents.EmailStatus = “: : Transmitting : :”

But obviously they arent getting to the php. Am i pathing things incorrectly?
[AS]
on(release){
if (!_root.contents.email.length || _root.contents.email.indexOf("@") == -1 || _root.contents.email.indexOf(".") == -1) {
_root.contents.EmailStatus = “Please check your email address.”;
} else if (!_root.contents.name.length) {
_root.contents.EmailStatus = “Please enter your name.”;
} else if (!_root.contents.comments.length) {
_root.contents.EmailStatus = “Please enter a message.”;
} else {
loadVariablesNum(“http://www.interaptive.com/mail.php”, “0”, “Post”);
_root.contents.EmailStatus = “: : Transmitting : :”;
}
}
[/AS]

O, and also, I did fix that little typo in the php mail line. ($Eamil) so it isnt that…
But I am really struggling here. What am I doing wrong?
Thanks =]

have you tried using this instead of _root?

well, wouldn’t ‘this’ refer to the send button movieclip, not contact.swf? (I just did a quick find n replace, and it doesnt work…)
Like I said, the variables are there and being read by flash interpreter ok, its just getting them out of flash thats causing all the problems.
I guess I really need to know how to properly path to the variables from the LoadVariablesNum statement.
Thanks for the suggestion though=]

Well then… there are other ways of getting those variables to the PHP script, I have used loadVariables by appending a “submit” variable at the end of the url and having a “submit == submit” if statment in the PHP to begin processing the script, I don’t know if that will help. It’s hard to say for me, I can’t really picture the context of the scipt in your work.
I have used this scipt nested way down in a flash movie and as long as all the form fields are together with the submit button, all in the same instance, then I do not use this or _root and it works fine.

Ok, well, context: root.swf has an empty mc, ‘contents’, which loads contact.swf. In there is a button mc, with the above AS on that movieclip.

This is really toying with my sanity. Obviously these methods work, just not for me =] I’m going to post up my fla and php. Someone please take pity on me and tell me what I am doing wrong before I create piles of pulled hair on my keyboard. Thanks very much =]

w00t=] finally got it fixed.
Just for the sake of anyone else who may encounter this problem, I used the movieclip.loadVariables instead of the global loadVariables function. This way you do not need to specify a target parameter (and therefore avoid all pathing woes for nested clips) just url and method.
so I ended up using
_root.contents.loadVariables(“filename.php”, “POST”);

i was just about to say that :slight_smile:
even thought i don’t know much about php