Forum Moderators: coopster
<?php
//create short variable names
$subject='Key Registration';
$name=$_POST['name_txt'];
$email=$_POST['email_txt'];
$location=$_POST['location_txt'];
$keyno=$_POST['keyno_txt'];
$comments=$_POST['comments_txt'];
$subject='Key Registration';
$name=trim($name);
$email=trim($email);
$location=StripSlashes($location);
$keyno=StripSlashes($keyno);
$comments=StripSlashes($comments);
/*#########
modify the next line with your own email address
###########*/
$toaddress='nmarinake@example.com';
mail($toaddress,$subject,$message,"From: $name <$email>\r\nReply-To: $email\r\nReturn-Path: $email\r\n");
//clear the variables
$subject = 'Key Registration';
$name='';
$email='';
$location='';
$keyno='';
$comments='';
echo "response=passed";
?>
And the URL link is here: <snip>
[edited by: dreamcatcher at 9:07 am (utc) on April 19, 2007]
[edit reason] no urls as per T.O.S [webmasterworld.com].Thanks [/edit]
/*-- FORMAT TEXT FIELDS
The next block of code deals with formatting the input
text fields. Styles are defined for the normal state and
the focus state. Next a for-in loop loops through the fields
passed to it and apply the normal formatting.*/
/*#######SET STYLES FOR TEXT FIELDS#######*/
//define styles for both normal and focussed
//set hex values here that work with your site's colors
normal_border = 0x000000;
focus_border = 0xFF0033;
normal_background = 0xFFFFFF;
focus_background = 0xFFFFFF;
normal_color = 0x000000;
focus_color = 0x000000;
//create an array containing the fields we wish to have styles applied to
inputs=[name_txt, email_txt, location_txt, keyno_txt, comments_txt];
/*
a "for in" loop now iterates through each element in the "inputs" array
and applies our "normal" formatting to each input text field
*/
for( var elem in inputs) {
inputs[elem].border = true;
inputs[elem].borderColor = normal_border;
inputs[elem].background = true;
inputs[elem].backgroundColor = normal_background;
inputs[elem].textColor = normal_color;
}
/*Now we address the highlighting that occurs when a text field
gains focus. We will use prototypes for this since it isn't
built into Flash:
-- SET AND KILL FOCUS METHODS --*/
TextField.prototype.onSetFocus = function() {
this.borderColor = focus_border;
this.backgroundColor = focus_background;
this.textColor = focus_color;
}
TextField.prototype.onKillFocus = function() {
this.borderColor = normal_border;
this.backgroundColor = normal_background;
this.textColor = normal_color;
}
//Be nice to your user by focussing the first field when the movie loads
Selection.setFocus(name_txt);
/*-- INITALIZE ENVIRONMENT
start off with submit button dimmed*/
submit._alpha = 40;
/*-- KEY LISTENER
Now we create a Listener Object which pays attention to the keyboard
and checks the state of the four input fields. The moment every text
field has at least something entered in it, the submit button "wakes up"
(this is strictly a visual cue - the button can be clicked at any time).
The fields could all have nonsense in them - this just checks to see that
SOMETHING exists in all four fields.*/
//create listener for Key Object
formCheck = new Object();
formCheck.onKeyUp = function() {
if (name_txt.text!= '' &&
email_txt.text!= '' &&
location_txt.text!= '' &&
keyno_txt.text!= '' &&
comments_txt.text!= '') {
//clear any alert messages
error_txt.text = '';
//enable the submit button
submit._alpha = 100;
} else {
//remain disabled until all fields have content
submit._alpha = 40;
}
}
//add this new listener
Key.addListener(formCheck);
//create the LoadVars objects which will be used later
//one to send data...
dataSender = new LoadVars();
//and one to catch what comes back
dataReceiver = new LoadVars();
/*DEFINE SUBMIT BUTTON BEHAVIOR*/
submit.onRelease = function() {
//final check to make sure fields are completed
if (name_txt.text!= '' &&
email_txt.text!= '' &&
location_txt.text!= '' &&
keyno_txt.text!= '' &&
comments_txt.text!= '') {
error_txt.text='';//clear any previous error messages or warnings
//advance playhead to frame 2 - the "processing" message
_root.play();
//assign properties to LoadVars object created previously
dataSender.name = name_txt.text;
dataSender.email = email_txt.text;
dataSender.location = location_txt.text;
dataSender.keyno = keyno_txt.text;
dataSender.comments = comments_txt.text;
//callback function - how to handle what comes back
dataReceiver.onLoad = function() {
if (this.response == "invalid") {
_root.gotoAndStop(1);
error_txt.text = "Please check email address."
} else if (this.response == "error") {
_root.gotoAndStop(3);
} else if (this.response == "passed") {
_root.gotoAndStop(4);
}
}
var targetPHP = "processEmail.php?now="+getTimer();
//now send data to script
dataSender.sendAndLoad(targetPHP, dataReceiver, "POST");
} else {
//warning if user tries to submit before completing form
error_txt.text = "Please complete all fields.";
}
}