View Full Version : Flash based PHP form contains html tags
capitalc17
October 7th, 2007, 03:08 PM
I've read about this same problem in other threads and I've tried the solutions. Hopefully, someone can help me. The website is www.lachezanddennis.com (http://www.lachezanddennis.com). The form is on the Guestbook page.
The form works, but the emails that I get look like this...
Name: <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"JUSTIFY\"><FONT FACE=\"Arial\"
SIZE=\"10\" COLOR=\"#FFFFFF\" LETTERSPACING=\"0\" KERNING=\"0\">LaChez</FONT>
</P></TEXTFORMAT>
All the message should say is:
Name: LaChez
but for some reason all the formatting is there.
The input is set to "input text"
The actionscript code basically looks to see if the words "Name", "Phone", etc. are in the input field, and if so, it clears the input field upon clicking inside of it.
//
label_01 = "Name";
label_02 = "Phone";
label_03 = "E-mail";
label_04 = "Subject";
label_05 = "Message";
//
name1 = label_01;
number1 = label_02;
email = label_03;
subject = label_04;
message1 = label_05;
//
this.onEnterFrame = function() {
txtfld1.onSetFocus = function() {
if (name1 == label_01) {
name1 = "";
}
};
txtfld1.onKillFocus = function() {
if (name1 == "") {
name1 = label_01;
}
};
//
txtfld2.onSetFocus = function() {
if (number1 == label_02) {
number1 = "";
}
};
txtfld2.onKillFocus = function() {
if (number1 == "") {
number1 = label_02;
}
};
//
txtfld3.onSetFocus = function() {
if (email == label_03) {
email = "";
}
};
txtfld3.onKillFocus = function() {
if (email == "") {
email = label_03;
}
};
//
txtfld4.onSetFocus = function() {
if (subject == label_04) {
subject = "";
}
};
txtfld4.onKillFocus = function() {
if (subject == "") {
subject = label_04;
}
};
//
txtfld5.onSetFocus = function() {
if (message1 == label_05) {
message1 = "";
}
};
txtfld5.onKillFocus = function() {
if (message1 == "") {
message1 = label_05;
}
};
};
stop();
Here is the PHP code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Wedding Guestbook</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?PHP
$to = "lachez_mccoy@hotmail.com";
$name=$_POST['name1'];
$number=$_POST['number1'];
$email=$_POST['email'];
$subject=$_POST['subject'];
$message=$_POST['message1'];
$msg .= "This message has been sent from your Wedding Guestbook.\n\n";
$msg .= "Name: $name\n";
$msg .= "Phone Number: $number\n";
$msg .= "Email: $email\n";
$msg .= "Message: $message\n";
mail($to,$subject, $msg, "From: Wedding Guestbook\nReply-To: $email\n");
?>
</body>
</html>
creatify
October 7th, 2007, 09:01 PM
use instance names for your input textfields and retrieve the data using yourtextfieldname.text - versus using variable names for the textFields. I think this is the issue.
capitalc17
October 8th, 2007, 12:22 AM
use instance names for your input textfields and retrieve the data using yourtextfieldname.text - versus using variable names for the textFields. I think this is the issue.
I tried it before, but I'll try it again. The instance names are txtfld1, txtfld2, txtfld3, etc.
So in my PHP file, I should change the variable names to txtfld1.text, txtfld2.text, etc?
creatify
October 8th, 2007, 12:08 PM
I'd need to see the code you're using to actually grab the input data and send it to the php. The php is ok I believe. I'm not sure why you're placing your set/kill focus items in an onEnterFrame? can you post fla with code?
I did a search, and can not find any really good Flash form samples - ones that aren't in AS1 syntax. ugggg.
capitalc17
October 8th, 2007, 06:10 PM
The .fla file can be downloaded at www.lachezanddennis.com/main2.fla (http://www.lachezanddennis.com/main2.fla)
From the Library, go to page 11.
This website is from a template. I'm just trying to get it to work properly.
I do believe the php is ok. I'm using the same code on another website and it works fine.
creatify
October 8th, 2007, 08:27 PM
I didn't test this but code goes in two places. And read my notes at the very bottom ;(
on that first frame in the form use this:
//
label_01 = "Name";
label_02 = "Phone";
label_03 = "E-mail";
label_04 = "Subject";
label_05 = "Message";
//
txtfld1.text = label_01;
txtfld2.text = label_02;
txtfld3.text = label_03;
txtfld4.text = label_04;
txtfld5.text = label_05;
//
this.onEnterFrame = function() {
txtfld1.onSetFocus = function() {
if (txtfld1.text == label_01) {
txtfld1.text = "";
}
};
txtfld1.onKillFocus = function() {
if (txtfld1.text == "") {
txtfld1.text = label_01;
}
};
//
txtfld2.onSetFocus = function() {
if (txtfld2.text == label_02) {
txtfld2.text = "";
}
};
txtfld2.onKillFocus = function() {
if (txtfld2.text == "") {
txtfld2.text = label_02;
}
};
//
txtfld3.onSetFocus = function() {
if (txtfld3.text == label_03) {
txtfld3.text = "";
}
};
txtfld3.onKillFocus = function() {
if (txtfld3.text == "") {
txtfld3.text = label_03;
}
};
//
txtfld4.onSetFocus = function() {
if (txtfld4.text == label_04) {
txtfld4.text = "";
}
};
txtfld4.onKillFocus = function() {
if (txtfld4.text == "") {
txtfld4.text = label_04;
}
};
//
txtfld5.onSetFocus = function() {
if (txtfld5.text == label_05) {
txtfld5.text = "";
}
};
txtfld5.onKillFocus = function() {
if (txtfld5.text == "") {
txtfld5.text = label_05;
}
};
};
stop();
on the submit button itself this hopefully should work:
on (rollOver) {
this.gotoAndPlay("over");
}
on (releaseOutside, rollOut) {
this.gotoAndPlay("out");
}
on (release) {
if (_root.pgapp.pages1.page11.txtfld1.text == "Name" ||
_root.pgapp.pages1.page11.txtfld2.text== "E-mail" ||
_root.pgapp.pages1.page11.txtfld3.text == "Phone" ||
_root.pgapp.pages1.page11.txtfld4.text == "Subject" ||
_root.pgapp.pages1.page11.txtfld5.text == "Message" ||
_root.pgapp.pages1.page11.txtfld1.text == "" ||
_root.pgapp.pages1.page11.txtfld2.text == "" ||
_root.pgapp.pages1.page11.txtfld3.text == "" ||
_root.pgapp.pages1.page11.txtfld4.text == "" ||
_root.pgapp.pages1.page11.txtfld5.text == "") {
_parent.gotoAndStop(3);
} else {
var nlv:LoadVars = new LoadVars();
nlv.name1 = txtfld1.text;
nlv.number1 = txtfld2.text;
nlv.email = txtfld3.text;
nlv.subject = txtfld4.text;
nlv.message1 = txtfld5.text;
nlv.sendAndLoad("email.php", nlv, "POST");
_parent.gotoAndStop(2);
}
}
the clear button - will have to modify that to match the first part of the frame code above.
I'm not saying this to be an arse or anything - and I haven't seen a ton of these templates sites' source files but: For anyone wanting to learn more flash, this template and at least two others I've seen, are the worst way to do it. I know that sounds harsh, and I understand why people use the templates. But the code is malformed, and way outdated the way its used. OnEnterFrames running errant which can bog the player big time etc etc. Just some advice - I've seen other posts on this and just try to make people aware. In order to make money on the templates they gotta cut corners someplace - we all do it, but, I've seen people actually buy them just to learn (kinda take it you're not doing this) - just my two cents, hope it doesn't come across too snotty.
capitalc17
October 9th, 2007, 12:30 AM
I don't think you're being snotty at all. In fact, I appreciate your honesty and help. I changed all the code to match your changes and the email looks like this:
This message has been sent from your Wedding Guestbook.
Name: undefined
Phone Number: undefined
Email: undefined
Message: undefined
creatify
October 9th, 2007, 01:01 AM
shoot - k, let me look at it first thing tomorrow.
creatify
October 9th, 2007, 12:53 PM
Hey there - I'm drawing a blank here, I can't figure it out. I don't have that orig. file you sent over, and I notice you took it down from your site. If you post again I can give another shot from the orig file again.
stotion
October 9th, 2007, 01:03 PM
I've seen (a few times) that it is my server that isn't preserving the variables. I've had Flash and PHP forms that will work well in certain domains but not on others. I've even had the case where the code will work well in certain directories of the same site but not in others. Often a simple request to the hosting company can clear things up with the "global variables" Good luck.
capitalc17
October 9th, 2007, 08:33 PM
Hey there - I'm drawing a blank here, I can't figure it out. I don't have that orig. file you sent over, and I notice you took it down from your site. If you post again I can give another shot from the orig file again.
Ok. I've posted the .fla file: www.lachezanddennis.com/main2.fla
creatify
October 10th, 2007, 01:05 PM
I wasn't thinking when I posted that previous code, place this code on the submit button, should work, if it doesn't its either the path to the php or the php itself. One question, on the php above, you have html tags in that? If thats on the server and now one every really views that, you can take the html out and just leave the php code in there:
on (rollOver) {
this.gotoAndPlay("over");
}
on (releaseOutside, rollOut) {
this.gotoAndPlay("out");
}
on (release) {
if (_root.pgapp.pages1.page11.txtfld1.text == "Name" ||
_root.pgapp.pages1.page11.txtfld2.text == "Phone" ||
_root.pgapp.pages1.page11.txtfld3.text == "E-mail" ||
_root.pgapp.pages1.page11.txtfld4.text == "Subject" ||
_root.pgapp.pages1.page11.txtfld5.text == "Message" ||
_root.pgapp.pages1.page11.txtfld1.text == "" ||
_root.pgapp.pages1.page11.txtfld2.text == "" ||
_root.pgapp.pages1.page11.txtfld3.text == "" ||
_root.pgapp.pages1.page11.txtfld4.text == "" ||
_root.pgapp.pages1.page11.txtfld5.text == "") {
_parent.gotoAndStop(3);
} else {
var nlv:LoadVars = new LoadVars();
nlv.name1 = _root.pgapp.pages1.page11.txtfld1.text;
nlv.number1 = _root.pgapp.pages1.page11.txtfld2.text;
nlv.email = _root.pgapp.pages1.page11.txtfld3.text;
nlv.subject = _root.pgapp.pages1.page11.txtfld4.text;
nlv.message1 = _root.pgapp.pages1.page11.txtfld5.text;
nlv.sendAndLoad("email.php", nlv, "POST");
_parent.gotoAndStop(2);
}
}
capitalc17
October 10th, 2007, 09:53 PM
Thank you so much. It works!!!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.