I am getting "unidentified" in places where First/Last Name and E-mail information should be. And this script has worked before so I know it must be a small mistake.
I got this small script that works with a flash movie on a website so that when they fill out the form (actionscripted) and submit the info it goes thru a php file to send an e-mail to my client so they recieve the name/email. Common setup.
First the Flash form is filled out....
Actionscript:
function clearForm() {
form.name_txt.text = "First Name";
form.email_txt.text = "Last Name";
form.msg_txt.text = "E-mail Address";
}
focusChange = new Object();
focusChange.onSetFocus = function(oldfocus,newfocus) {
if (newfocus != oldfocus) {
if(newfocus == form.name_txt) { if (form.name_txt.text == "First Name") { form.name_txt.text = "" } };
if(newfocus == form.email_txt) { if (form.email_txt.text == "Last Name") { form.email_txt.text = "" } };
if(newfocus == form.msg_txt) { if (form.msg_txt.text == "E-mail Address") { form.msg_txt.text = "" } };
}
}
Selection.addListener(focusChange);
clearForm();
sent_text._visible = false;
var contact_php_file = "flashEmailer.php";
send_btn.onRelease = function() {
sendEmail(n, e, m);
clearForm();
}
function validateEmail(address) {
// Check address length
if(address.length >= 7) {
// Check for an @ sign
if(address.indexOf("@") > 0) {
// Check for at least 2 characters following the @
if((address.indexOf("@") + 2)<address.lastIndexOf(".")) {
// Check for a domain name of at least 2 characters
if (address.lastIndexOf(".") < (address.length - 2)) {
// If all the above tests pass, the email address is in valid format
return true;
}
}
}
}
// Called if the email fails
trace("The entered email address is invalid.");
return false;
}
function checkForm() {
n = form.name_txt.text;
e = form.email_txt.text;
m = form.msg_txt.text;
if(m != "" && e != "" && validateEmail(m)) {
sendEmail(n, e, m);
} else {
trace("All Required Fields Not Filled In!");
}
}
function sendEmail(n, e, m) {
session = "?nocache=" + random(999999);
contact_lv = new LoadVars();
contact_lv.name = n;
contact_lv.email = e;
contact_lv.message = m;
contact_lv.key = "email";
trace(n + " - " + e + " - " + m);
sent_text._visible = true;
contact_lv.sendAndLoad(contact_php_file + session, contact_lv, "POST");
contact_lv.onLoad = function(success) {
if(!success) {
return trace("Error calling PHP File!");
} else {
return trace("Email Sent!");
sent_text._visible = true;
}
}
}
stop();
---Talks to the php here----------------------------------------
<?php
/*----------------------------------------------------------
Author : www.mkeefedesign.com | Matthew Keefe
Contact : matt [/at/] mkeefedesign [/period/] com
$Id: send_email.php ,v 1.0 Tue Apr 26, 2005 02:20 PM
------------------------------------------------------------
* CODING & DESIGN ©2004 mkeefeDESIGN | ALL RIGHTS RESERVED
------------------------------------------------------------*/
$recipients = "example@example.com" . ",";
$subject = "A subscriber from your website - JakiaOnline.com";
// Grab the key from Flash to ensure security
$sendKey = $_POST['key'];
// Only allow the page to send if Flash is the requester
if($sendKey == "email") {
// The following three variables are gathered from Flash
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
// Grab todays date
$date = date("F j, Y", time());
// This block is the actual message that is sent in the email
$email_info .= "Below is the visitors contact info and message.\n\n";
$email_info .= "Visitor's Info:\n";
$email_info .= "-----------------------------------------\n";
$email_info .= "Name: " . $name . "\n";
$email_info .= "Email: " . $email . "\n";
$email_info .= "Date Sent: " . $date . "\n\n";
$email_info .= "Message\n";
$email_info .= "-----------------------------------------\n";
$email_info .= "" . $message . "\n";
$mailheaders = "From: Jakia Music Online <example@example.com> \n";
$mailheaders .= "Reply-To: " . $email . "\n\n";
if(mail($recipients, $subject, $email_info, $mailheaders)) {
// Print a success for Flash to know the email is being sent
print "&success=true";
}
}
?>
---And my results that are e-mailed to me look like this-----------------
Below is the visitors contact info and message.
Visitor's Info:
Name: undefined
Email: undefined
Date Sent: March 14, 2009
Message
undefined
Thanks so much 🙂