-
HELP. need help with flash php email form
i am trying to make my form except more then just email name and body
here is my php code
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$feedback = $_POST['feedback'] ;
$subject = 'Feedback from ';
$headers = "From: $name <$email>\n";
$headers .= "Reply-To: $name <$email>\n";
$to = 'aj@youremail.net';
$success = mail($to, $subject, $feedback, $headers);
if($success){
echo '&sent=OK';
}else{
echo '&sent=Error';
}
?>
my flash does this
var sendData_lv:LoadVars = new LoadVars();
var receiveData_lv:LoadVars = new LoadVars();
var formValidated:Boolean;
var errorMessages:Array = new Array();
receiveData_lv.onLoad = function():Void{
trace(this.sent);
if(this.sent == "OK"){
message0_txt.text = "Thank you for your feedback";
}else{
message0_txt.text = this.sent;
}
}
submit_btn.onRelease = function() {
clearTextFields();
errorMessages.length = 0;
formValidated = checkForm();
if (formValidated) {
sendData_lv.name = name_txt.text;
sendData_lv.email = email_txt.text;
sendData_lv.feedback = feedback_txt.text;
(sendData_lv.email);
("valid");
sendData_lv.sendAndLoad("email.php?ck="+new Date().getTime(), receiveData_lv);
} else {
for (var i = 0; i<errorMessages.length; i++) {
_root["message"+i+"_txt"].text = errorMessages[i];
trace(errorMessages[i]);
}
}
};
function checkForm():Boolean {
if (name_txt.text == "") {
errorMessages.push("Please enter your name.");
}
if (email_txt.text == "") {
errorMessages.push("Please enter your email address.");
} else if (email_txt.text.indexOf("@") == -1 || email_txt.text.indexOf(".") == -1) {
errorMessages.push("Please enter a valid email address.");
}
if (feedback_txt.text == "") {
errorMessages.push("Please enter some feedback");
}
if (errorMessages.length == 0) {
return true;
} else {
return false;
}
}
function clearTextFields():Void {
for (var i = 0; i<errorMessages.length; i++) {
_root["message"+i+"_txt"].text = "";
;
}
}
i want to add atleast 3 to four more fields to this any help or direction would be great
-
Simple. Add a few more fields in flash and assign them to sendData like you did everything else:
e.g. sendData_lv.city = city_txt.text;
Then, attach those to your feedback variable in PHP like so:
$feedback = "Feedback: ".$_POST['feedback'] ."\r\n";
$feedback.= "City: ".$_POST['city']."\r\n";
Notice the \r\n (linebreak in a plain text e-mail) and the dot-equals which means "add this to the feedback variable without replacing it".
I also added "City: " and "Feedback: " so you knew what the responses where to in your e-mail.
Make sense?
-
thanks. yeah the dot is where i was messing up. Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|