ok, I just took the original code you sent, make sure the PHP filename was "mailer.php". When you fill the form and click "send" (in french, "envoyer"), it stays at the "processing" window forever, it doesn't jump to the "complete" window, [u]but I do reveive the form via email.
Here's the AS3 code:
- Code: Select all
stop();
send_btn.addEventListener(MouseEvent.CLICK, sendClicked);
email_box.addEventListener(FocusEvent.FOCUS_IN, focused);
subject_box.addEventListener(FocusEvent.FOCUS_IN, focused);
message_box.addEventListener(FocusEvent.FOCUS_IN, focused);
function sendClicked(ev:MouseEvent):void {
var req:URLRequest = new URLRequest("mailer.php");
var vars:URLVariables = new URLVariables();
var loader:URLLoader = new URLLoader();
vars.sender = email_box.text;
vars.subject = subject_box.text;
vars.message = message_box.text;
req.method = URLRequestMethod.POST;
req.data = vars;
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, sent);
loader.addEventListener(IOErrorEvent.IO_ERROR, unableToSend);
if (vars.sender != "" && vars.subject != "" && vars.message != "") {
loader.load(req);
gotoAndStop(2);
} else {
error_clip.gotoAndPlay(2);
}
}
function sent(ev:Event):void {
gotoAndStop(3);
}
function unableToSend(ev:IOErrorEvent):void {
trace("Unable to reach php file.");
}
function focused(ev:FocusEvent):void {
if(error_clip.currentFrame != 1) {
error_clip.gotoAndPlay(6);
}
}
Here's the PHP code:
- Code: Select all
<?php
/* ---------------------------
php and flash contact form.
by www.MacromediaHelp.com
---------------------------
Note: most servers require that one of the emails (sender or receiver) to be an email hosted by same server,
so make sure your email (on last line of this file) is one hosted on same server.
--------------------------- */
// read the variables form the string, (this is not needed with some servers).
$subject = $_REQUEST["subject"];
$message = $_REQUEST["message"];
$sender = $_REQUEST["sender"];
// include sender IP in the message.
$full_message = $_SERVER['REMOTE_ADDR'] . "\n\n" . $message;
$message= $full_message;
// remove the backslashes that normally appears when entering " or '
$message = stripslashes($message);
$subject = stripslashes($subject);
$sender = stripslashes($sender);
// add a prefix in the subject line so that you know the email was sent by online form
$subject = "Contact form ". $subject;
// send the email, make sure you replace email@yourserver.com with your email address
if(isset($message) and isset($subject) and isset($sender)){
mail("form@dbpromedia.com", $subject, $message, "From: $sender");
}
?>
I attached a zip file that contain both fla and php files, mabye you'll find something! Thanks a lot.