Hi Everyone,
Another newby here with hat in hand. I'm working on a basic flash/php mail program. Working with the template provide from a website; I want some additional fields to the formmail. So I added some text boxes to the .FLA file which sends the variables to the PHP file.
I thought it would be simple enough to do, but I'm still not getting the output I want; showing all the text fields in the email.
This is the actionscript for the .FLA file
stop();
name_box.tabIndex = 1;
phone_box.tabIndex = 2;
subject_box.tabIndex = 3;
email_box.tabIndex = 4;
street_box.tabIndex = 5;
po_box.tabIndex = 6;
city_box.tabIndex = 7;
state_box.tabIndex = 8;
zip_box.tabIndex = 9;
ccomments_box.tabIndex = 10;
send_btn.onRelease = function() {
my_vars = new LoadVars();
my_vars.cname = name_box.text;
my_vars.cphone = phone_box.text;
my_vars.csubject = subject_box.text;
my_vars.csender = email_box.text;
my_vars.cstreet = street_box.text;
my_vars.cpo = po_box.text;
my_vars.ccity = city_box.text;
my_vars.cstate = state_box.text;
my_vars.czip = zip_box.text;
my_vars.ccomments = ccomments_box.text;
if (my_vars.csender != "" and my_vars.csubject != "" and my_vars.ccomments != ""and my_vars.cstate != "" and my_vars.czip != "") {
my_vars.sendAndLoad("mailer.php", my_vars, "POST");
gotoAndStop("success");
} else {
error_clip.gotoAndPlay("success");
}
my_vars.onLoad = function() {
gotoAndStop("fail");
};
};
email_box.onSetFocus=csubject_box.onSetFocus=cmessage_box.onSetFocus=function () {
if (error_clip._currentframe != 1) {
error_clip.gotoAndPlay(6);
}
};
/*email_box.onSetFocus = subject_box.onSetFocus=message_box.onSetFocus=function () {
if (error_clip._currentframe != 1) {
error_clip.gotoAndPlay(6);
}
};
*/
and this is the code on the php side
<?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).
$csubject = $_REQUEST["subject"];
$cname = $_REQUEST["name"];
$cphone = $_REQUEST["phone"];
$cstreet = $_REQUEST["street"];
$cpo = $_REQUEST["po"];
$ccity = $_REQUEST["city"];
$cstate = $_REQUEST["state"];
$czip = $_REQUEST["zip"];
$ccomments = $_REQUEST["ccomments"];
$csender = $_REQUEST["sender"];
// include sender IP in the message.
$full_message = $_SERVER['REMOTE_ADDR'] . "\n\n" . $ccomments . "\n\n" . $cname . "\n\n" . $cphone . "\n\n" . $cstreet . "\n\n" . $cpo . "\n\n" . $ccity . "\n\n" . $cstate . "\n\n" . $czip;
$message= $full_message;
// remove the backslashes that normally appears when entering " or '
$message = stripslashes($message);
$subject = stripslashes($csubject);
$sender = stripslashes($csender);
// 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("administrator@gnci.net", $subject, $message, "From: $sender");
}
?>
and this is the email that I get
------------------------------------------------------
Sent: Tuesday, October 30, 2007 2:10 AM
To: Administrator
Subject: Contact form
comments3
--------------------------------------------------