-
[F8] Feedback Form:eMail
Hello everybody.
Can anyone point out any tutorials that are easy to understand and will teach me how to send a email using a .cgi script and flash's loadVariables? I been using this Flash 5 Bible but that don't seem to work, actually EVERY tutorial i get on a book doesn't seem to work! :yikes:
Im rubbish with perl scriptile language.
Thanks
Tongxn.
-
more or less...the FLASH (AS) will be the same...
its the backend script that will be different. Sorry I dont have any examples using CGI..only PHP...
-
-
does your web host support PHP?
(if not, drop them..its free, and should be offered as such) ;)
-
I can walk you through how to set up a loadVar Object..and send if off to a PHP script, that also returns a message, saying it went "OK" or "NOT OK"...
-
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");
}
so basically form the example above...
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")
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!");
}
?>
I think that should do it...
-
Looks clever, cant you do the $Subject and all that using getURL?
I'll try it out,
Thanks whispers.