so basically form the example above...Code:on (release) { sendIt = new LoadVars(); // user details // // here we're collecting the text that was input into the textFields in your form. sendIt.userName = userName_txt.text; sendIt.userEmail = userEmail_txt.text; sendIt.userPhone = userPhone_txt.text; sendIt.extraData = extraData_txt.text; // usually you would NOT declare an 'onLoad' action, but since we are using 'sendAndLoad' instead of 'load' // for our action we can declare a group of events to excute depending on the outcome of the email atempt. sendIt.onLoad = function(success) { if (success) { //mailSent is a variable echo'd in the PHP file. response_txt.text = sendIt.mailSent; trace("vars loaded/reply returned"); trace("Outcome: "+sendIt.mailSent); } } // using sendAndLoad, lets us declare an object in the paramters to 'handle' the return from our PHP file // in this example were using the SAME object that we used to gather and SEND the data to handle the LOADing of the data response. sendIt.sendAndLoad("http://www.yourdomain.com/tryEmail.php", sendIt, POST); trace ("sending vars"); }
you should have '4' input fields on your stage. (and 1 button, with this code on it)
the input field names should be as follows:
username_txt
userEmail_txt
userPhone_txt
extraData_txt
(you can change these gather whatever data you want though)
this is the PHP script you should have to handle this example above. (I have added some HTML tags so the email has some minor "color/formatting")
I think that should do it...PHP Code:<?php
$cuserName=$_POST["userName"];
$userEmail=$_POST["userEmail"];
$userPhone=$_POST["userPhone"];
$extraData=$_POST["extraData"];
$MailTo = "recipient@email_here.com";
$Subject = "Email Subject Line Here";
$Body = "<B><font color=#A80B0B>From: </font></B>$userName<BR><B><font color=#A80B0B>E-mail:</font></B> <A HREF=mailto:$userEmail>$userEmail</A><BR><B><font color=#A80B0B>Phone: </font></B>$userPhone<BR><br><br><B><font color=#000000>Extra Data/Comments: </font></B><BR><BR>$extraData<BR>";
$headers = "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: Whoever the email should be from";
$sendMail = mail($MailTo, "$Subject", "$Body", "$headers");
if(sendMail) {
echo ("&mailSent=Successfully!");
} else {
echo ("&mailSent=Unsuccessfully!");
}
?>




Reply With Quote