flash mailform med php
Hej, jeg har fundet en mailform på nettet som bruger php til at sende mail'en.Men når jeg ligger det ind i min egen flash movie begynder problemerne.
den vil sagtens sende mail'en, men den sender ikke noget indhold med.
Mit actionscript ser sådan ud:
function checkAddress(sender_email) {
//
var FirstAT = sender_email.indexOf("@");
// placement of the first "@" in "sender_email"
var LastAt = sender_email.lastIndexOf("@");
// placement of the last "@" in "sender_email"
var theLength = sender_email.length;
// Number of characters in "sender_email"
var LastDot = sender_email.lastIndexOf(".");
// placement of the last "." (dot) in "sender_email"
var specialCharacter = " ~!$^&*()+|=`[]{};:<>,?/\\\"'\r\n";
//%# removed
// Characters that are not allowed in an emailaddress
//
trace("FirstAT : "+FirstAT);
trace("LastAt : "+LastAt);
trace("theLength : "+theLength);
trace("LastDot : "+LastDot);
//
if (sender_name == "") {
// if sender_name is empty
problemo = "Fill in your name - Please!";
// error Output
return false;
}
//
if (sender_email == "") {
// if sender_email is empty
problemo = "Fill in your Email - Please!";
// error Output
return false;
}
//
if (FirstAT != LastAt || FirstAT<1 || FirstAT>(theLength-4)) {
// 1) If "FirstAT" is not equal "LastAt" it tells us that there is more than one "@"
// 2) If "FirstAT" is smaller than 1 (there must be at least on character before the "@")
// 3) If FirstAt is bigger than the length of "sender_email" minus 4. (there will allways
// be at least on dot an 3 characters after the "@")
problemo = "Please check your Email - it is not correct!";
// error Output
return false;
}
//
if (LastAT>LastDot) {
// Makes sure that LastDot if placed AFTER last AT (@)
problemo = "Please check placement of \".\" (dot) in your Email - it is not correct!";
// error Output
return false;
}
//
if ((theLength-lastDot)<3 || (theLength-lastDot)>5) {
// 1) If the length minus last dot is less than 3 (There must be at least a dot and two characters in the end of an Email)
// 2) If the length minus last dot is more than 5 (There can be no more than 4 characters after the dot in an Email)
problemo = "Please check your Email - it is not correct!";
// error Output
return false;
}
//
for (i=0; i<specialCharacter.length; i++) {
// loop
if (sender_email.indexOf(specialCharacter.substr(i, 1))>=0) {
// "indexOf" returns the value "-1" if the character is NOT in "sender_mail"
// If the retur of this "for loop" is greater than zero there IS an nonvalid character in "sender_email"
problemo = "There seems to be a nonvalid character in your Email!";
// error Output
return false;
}
}
//
if (sender_email.length<=5) {
// (An email must contain more than 5 characters incl. @ and . )
problemo = "Your Email contains less than 6 characters and is therefor not valid!";
// error Output
return false;
}
//
if ((LastAt+1) == LastDot) {
// There must be characters between @ and .
problemo = "There must be characters between \"@\" and \".\" (dot) in your Email!";
// error Output
return false;
}
//
if (message == "" || message == " " || message == " ") {
// if message is empty
problemo = "You didn't write any message!";
// error Output
return false;
}
return true;
}
Og den ligger i root.
Min php fil ser således ud:
// Write the emailadress where the input
// from the Flash-emailform should be send to
$sendTo = "per@cphplayers.com";
// Write a subject - that will be seen as subject when you'll receive the mail
$subject = "Email fra DD";
// Header information that all goes into one variable.
// (Not including sendTo and Subject)
// The UTF8_decode makes it possible to write special characters like the danish letters æ.ø,å
$headers = "From: " . utf8_decode($_POST["sender_name"]) . "<" . $_POST["sender_email"] .">\r\n";
// Replyto is included
$headers .= "Reply-To: " . $_POST["sender_email"] . "\r\n";
// Ofcause the email can only be returned if the emailadress is correct ;-)
$headers .= "Return-path: " . $_POST["sender_email"];
// First i like to make a row of stars ... for no reason really :-)
$message = "************************************************************\r\n";
// Now we can add the content of the message to a body variable
$message .= utf8_decode($_POST["message"]);
// ..... and again after the message from the form; another row of stars
$message .= "\n\n************************************************************\r\n";
// Now we are ready to send the email - with the PHP-function mail();
mail($sendTo, $subject, $message, $headers);
?>
og den ligger i root/mailform
håber der er en eller flere der kan hjælpe
På forhånd tak
Per
