PDA

View Full Version : Flash & PHP form not working!


Head In A Pan
07-19-2007, 01:07 AM
HellO!

I am so frustrated! I tested this script and the server lagged with the actual posting, so after numerous changes the mail filtered through... I can't get it working again.
If anyone can help it would be so cool.

FLASH

//Submit data to PHP & send if boxes are correct!
function sendMail() {

var newsLetter:LoadVars = new LoadVars();

var email:LoadVars = new LoadVars();
email.email_address = email_address.text;//Email
email.first_name = first_name.text;//First Name
email.surname = surname.text;//Surname
email.mobile = mobile.text;//Mobile
email.post_code = post_code.text;//Post Code


//Trace
trace (email_address.text);//Email
trace (first_name.text);//First Name
trace (surname.text);//Surname
trace (mobile.text);//Mobile
trace (post_code.text);//Post Code


valid_txt = "";

//Post data

email.sendAndLoad("newsletter.php", newsLetter, "POST");

thankYou();
};



PHP

<?

$to = "my@email.com";


$subject = "Subscriber";

$headers = "From: $MailFrom" . $_POST["email_address"];
$headers .= "<" . $_POST["email_address"] . ">\r\n";
$headers .= "Reply-To: " . $_POST["email_address"] . "\r\n";
$headers .= "Return-Path: " . $_POST["email_address"];


$text = $_POST['email_address'];
$text = $_POST['first_name'];
$text = $_POST['surname'];
$text = $_POST['mobile'];
$text = $_POST['post_code'];


$msg .= "Email: $_POST[email_address]\n";
$msg .= "Name: $_POST[first_name]\n";
$msg .= "Surname: $_POST[surname]\n";
$msg .= "Mobile: $_POST[mobile]\n";
$msg .= "Post Code: $_POST[post_code]\n";

mail($to, $subject, $msg, $headers);

$filename = "answer.txt";
$fd = fopen( $filename, "r" );
$contents = fread( $fd, filesize( $filename ) );
fclose( $fd );
$headers2 = "<" . $_POST["email_address"] . ">\r\n";

mail("$headers2", "Reply Header", "$contents\n\n",
"From:my@email.com\n");

$signal=1;
echo "signal=$signal";

?>

spriggan
07-19-2007, 06:46 AM
ok so I'm not sure I follow. The code was originally working but now doesn't after the server spike? If that's the case you're host may have marked you as a possible spammer and placed a limit on your outgoing mail (most hosts have restrictions to this).

If that's not the case, have you tracked down where it's failing? Do you know everything is getting passed from flash to the PHP scripts (just by using echos to make sure)? Because everything looks kosher to me.

Another thing you can to is to just test the PHP by sending everything in via a HTML form and removing flash from the equation.