|
<?php
/*
* Form to mail service
* Author: Jorge Solis
* Site: www.flash-db.com/remoting/
*/
class formToMail{
function formToMail(){
$this->methodTable = array(
"sendForm" => array(
"description" => "Sends the contact form",
"access" => "remote", // available values are private, public, remote
"arguments" => array ("from", "email", "message"),
"returntype" => "String"
)
);
}
function sendForm($from, $email, $message){
$to = "Your email here"; //Change this to match your needs !!!
$text = "Message from contact form\n\nName: $from\nEmail: $email\nMessage: $message";
if( mail($to, "Contact form", $text, "From: ".$from ." < ".$email." >")) return "Ok";
else return "Error";
}
}
?>
|
|
//AS1 version
#include "NetServices.as"
#include "NetDebug.as"
///////////////////////////////////////////
//Requests Handlers
///////////////////////////////////////////
sendForm_Result = function(texto){
if(texto=="Error") {
status.text = "Error sending email"
name.backgroundColor = email.backgroundColor = message.backgroundColor = 0xFFFFFF
} else gotoAndStop("Sended")
}
//////////////////////////////////////////
// Connection to service
//////////////////////////////////////////
var conn = NetServices.createGatewayConnection("http:// path to your gateway.php");
// Specify the service you want to use. There has to be a file called 'formToMail.php' in your
// services directory.
var myService = conn.getService("formToMail", this);
//////////////////////////////////////
//Components handlers
///////////////////////////////////////
function send(comp){
if(name.text.length<4) {
//Name at least 4 characters
name.text = "<Insert your firstname - lastname>"
name.setFocus()
return
}
//Email at least 5 characters and a "@"
if(email.text.length<5 || email.text.indexOf("@")==-1) {
email.text = "<Insert a valid email>"
email.setFocus()
return
}
//Background gray while sending
name.backgroundColor = email.backgroundColor = message.backgroundColor = 0xCCCCCC
//Call the service
myService.sendForm(name.text, email.text, message.text)
}
stop()
|