| | |
Contact form Flash/PHP sends with Text Formatting
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2008
Posts: 3
Reputation:
Solved Threads: 0
Hi, I would like some help please. I have made a contact form on Flash and called on a PHP file to send the form through mail. When I receive the e-mail, it is all messed up with HTML tags of the text formatting everywhere... Even in the "From" and "Subject" part.. Can anybody help me take the formatting off? Is a very simple PHP action, below you will find the flash actionscript (very simple) and the PHP script I am using. Please help!! 
Here is the example of the mail I am receiving:
Name:<TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"_sans\" SIZE=\"12\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">John Smith</FONT></P></TEXTFORMAT> E-mail <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"_sans\" SIZE=\"12\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">ldskjflk</FONT></P></TEXTFORMAT>
Address: <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"_sans\" SIZE=\"12\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">jlkjlkj</FONT></P></TEXTFORMAT>
Message: <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Arial\" SIZE=\"12\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">lkjlkjlkj</FONT></P></TEXTFORMAT>
here is the actionscript from flash:
stop();
sendBtn.onRelease = function() {
formText._visible=false;
form.loadVariables("email1.php", "POST");
}
and here is the PHP script I am using:
<?php
$sendTo = 'info@bhbmarketingsolutions.com';
$subject = 'Contact from BHB Marketing Solutions Web Page';
$message = "Nombre: $nombre
E-mail $email
Dirección: $direccion
Telefono: $telefono
Codigo Postal: $cp
Pais: $pais
Provincia: $provincia
Comentario: $mess";
$headers = 'From: ' . $_POST['nombre'];
mail($sendTo, $subject, $message, $headers);
?>
I think it may probably be a Flash issue?? or can this be done through PHP?
I read a post in this forum from months ago with kind of the same problem, but the problem wasn't solved. Here is the link of the other post:
http://www.daniweb.com/forums/thread90716.html
And the solution seems to be quite simple.. I tried to do this, but instead of receiving an HTML message, I receive all the HTML tags of the suppossed "HTML" message.
Can someone help me?

Here is the example of the mail I am receiving:
Name:<TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"_sans\" SIZE=\"12\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">John Smith</FONT></P></TEXTFORMAT> E-mail <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"_sans\" SIZE=\"12\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">ldskjflk</FONT></P></TEXTFORMAT>
Address: <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"_sans\" SIZE=\"12\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">jlkjlkj</FONT></P></TEXTFORMAT>
Message: <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Arial\" SIZE=\"12\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">lkjlkjlkj</FONT></P></TEXTFORMAT>
here is the actionscript from flash:
stop();
sendBtn.onRelease = function() {
formText._visible=false;
form.loadVariables("email1.php", "POST");
}
and here is the PHP script I am using:
<?php
$sendTo = 'info@bhbmarketingsolutions.com';
$subject = 'Contact from BHB Marketing Solutions Web Page';
$message = "Nombre: $nombre
E-mail $email
Dirección: $direccion
Telefono: $telefono
Codigo Postal: $cp
Pais: $pais
Provincia: $provincia
Comentario: $mess";
$headers = 'From: ' . $_POST['nombre'];
mail($sendTo, $subject, $message, $headers);
?>
I think it may probably be a Flash issue?? or can this be done through PHP?
I read a post in this forum from months ago with kind of the same problem, but the problem wasn't solved. Here is the link of the other post:
http://www.daniweb.com/forums/thread90716.html
And the solution seems to be quite simple.. I tried to do this, but instead of receiving an HTML message, I receive all the HTML tags of the suppossed "HTML" message.
Can someone help me?
you need the send the content-type header with the script so it will be displayed as html not text.
replace:
with:
replace:
PHP Syntax (Toggle Plain Text)
$headers = 'From: ' . $_POST['nombre'];
with:
PHP Syntax (Toggle Plain Text)
$headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n";
•
•
Join Date: Mar 2008
Posts: 3
Reputation:
Solved Threads: 0
Thanks alot, you really fixed all the problem, however I have just a little problem still... All the message of the mail is displayed great, as HTML and everything is good. Now the only problem is the "From" part of the mail it keeps on displaying the HTML code. So, the subject is ok, the message is ok, put the "from" keeps on displaying the tags... any ideas?
Thank you very much for your help, it was really useful
Thank you very much for your help, it was really useful
•
•
Join Date: Mar 2008
Posts: 7
Reputation:
Solved Threads: 0
Hi, sense you're using AS 2.0, i may consider the use of the sendAndLoad function, and make your PHP return something like a boolean flag, so on the cliente side (flash) you can tell the user either the mail was sent successfully or not.
You can add an eventListner on the flash side that listens for a php reply, and checks either is TRUE ou FALSE, so you can show the user an acurate message.
But, going from you're now, why is the flash passing all that HTML? can't you pass only the values you need and then paste them on the PHP along with the HTML?
That will solve you problems about the HTML entities and tags.
Will help you satitaze your data, either on the flash side, to make sure the data you're sending to the php is in real what you whant it to be.
And will help you validate that data on the server side (you can never trust the user allways validate you data).
And finaly the amount of data being trade from client to server and backwords will be a lot less, so you will save bandwith.
You can add an eventListner on the flash side that listens for a php reply, and checks either is TRUE ou FALSE, so you can show the user an acurate message.
But, going from you're now, why is the flash passing all that HTML? can't you pass only the values you need and then paste them on the PHP along with the HTML?
That will solve you problems about the HTML entities and tags.
Will help you satitaze your data, either on the flash side, to make sure the data you're sending to the php is in real what you whant it to be.
And will help you validate that data on the server side (you can never trust the user allways validate you data).
And finaly the amount of data being trade from client to server and backwords will be a lot less, so you will save bandwith.
Last edited by miguelp; Mar 4th, 2008 at 5:46 am.
•
•
Join Date: Mar 2008
Posts: 3
Reputation:
Solved Threads: 0
Well.. as you can see I am using a very easy flash form to send the information to my e-mail. I am using the following:
onClipEvent(data){
_root.nextFrame();
}
So that when the data is sent, the user may receive a notification message that the data has been sent.
However, I am reading about the sendAndLoad function, and I tried to make it work, but to tell you the truth I am not that good Action sript programmer, so I have to get into Actionscript more so that I know how exactly that works. And adding an eventListner would be helpful, unfortunately I don't know exactly how that works.
As for the HTML I already figured out why the message came with all the HTML tags in the message and already have been able to fix it. But It would be really helpful if you could assist me in the flash part of the boolean flag, eventListener, and sendAndLoad...
I could easily send you the files over mail or something and you can help me with that? Please let me know... I really appreciate it.
onClipEvent(data){
_root.nextFrame();
}
So that when the data is sent, the user may receive a notification message that the data has been sent.
However, I am reading about the sendAndLoad function, and I tried to make it work, but to tell you the truth I am not that good Action sript programmer, so I have to get into Actionscript more so that I know how exactly that works. And adding an eventListner would be helpful, unfortunately I don't know exactly how that works.
As for the HTML I already figured out why the message came with all the HTML tags in the message and already have been able to fix it. But It would be really helpful if you could assist me in the flash part of the boolean flag, eventListener, and sendAndLoad...
I could easily send you the files over mail or something and you can help me with that? Please let me know... I really appreciate it.
•
•
Join Date: Mar 2008
Posts: 7
Reputation:
Solved Threads: 0
ok, lets do what good programmers do and devide the problem, my english is not very good but i'll try my best, to make you understand.
Lets start with the most important thing that is getting confirmation from the PHP into our flash movie, using the sendAndLoad object.
Ok first of all in order to use the sendAndLoad you'll need 2 loadVars objects, one for getting the data to be sent and the other one that will store the data PHP gives back.
The code to do this may become a little extensive, so i recomend using a function to store this methods and the comunication, this way it will be easyer to debug later.
So here's the code:
OK so in the frame the clip will jump to create a dynamic text field and under the properties tab you've got a a box called "var" this is use to associate a dynamic text field with a variable, every time the value of the variable changes so the text field. so in this case give "msg" as name the text field var, so it will display the message.
In the php if the email is sent without problems make an echo of the success message like:
or you create an error description to deal on flash side like
let me know if you get this so far and if it helps.
Lets start with the most important thing that is getting confirmation from the PHP into our flash movie, using the sendAndLoad object.
Ok first of all in order to use the sendAndLoad you'll need 2 loadVars objects, one for getting the data to be sent and the other one that will store the data PHP gives back.
The code to do this may become a little extensive, so i recomend using a function to store this methods and the comunication, this way it will be easyer to debug later.
So here's the code:
Actionscript Syntax (Toggle Plain Text)
// Lets create a function function sendEmail():Void { // lets create the object to store the data to be sent. var sendData = new LoadVars(); // ok now lets fill this object with the actual data // in order to do this you simply add a dot and the name you will use // in the POST index. For example sendData.Message = "abc" you will be able to catch // the value in PHP like echo $_POST['Message']; that will output: abc sendData.Name = _root.form.Name.text; sendData.Message = _root.form.Message.text; // so on... add as much elements as the fields you what to send. // ok now we need the object to store the data PHP will give you back var getData = new LoadVars(); // ok now we have data to send and an object to store the reply. // lets see the sendAndLoad method: // this method requires 3 parameters in the order URL, TargetObject, Method // URL is the name and path of the PHP file you're calling for example "include/form.php" // or simply form.php if the PHP file is in the sabe directory of the flash movie // targetObject is the object that will hold the reply data in our case the getData var we created // Method is the method to be used to send the data so in this case it will be POST sendData.sendAndLoad("url.php", getData, "POST"); // ok so we collected the data and have send it to PHP now we need the reply // so lets use the eventListenner that we have in LoadVars called onLoad and // make something with that data. getData.onLoad = function(success:Boolean){ // ok function is created, but see that i require a boolean value // in order to know if the flash loaded some Data, if so we will process that data // otherwise store a message in a msg var if(success){ // ok by this point we have data to show, now lets see if we got errors // if we do we add the errors to a var so we can deal with it later if we don't, // we will store the message returned by PHP into an msg var. if(getData.Errors){ // store the error on a variable var error = getData.Errors; // call a function that will deal with your error, and pass the error var as a parameter _root.dealWithError(error); }else{ //store the message in a msg var msg = getData.Msg; // tell root to go to the next frame _root.nextFrame(); } }else{ // store the connection error in a msg msg = "Connection error: unable to contact the server"; // tell root to go to the next frame _root.nextFrame(); } } }
OK so in the frame the clip will jump to create a dynamic text field and under the properties tab you've got a a box called "var" this is use to associate a dynamic text field with a variable, every time the value of the variable changes so the text field. so in this case give "msg" as name the text field var, so it will display the message.
In the php if the email is sent without problems make an echo of the success message like:
php Syntax (Toggle Plain Text)
<?php echo "&msg= your message"; ?>
or you create an error description to deal on flash side like
php Syntax (Toggle Plain Text)
<?php echo "&error= your error message"; ?>
let me know if you get this so far and if it helps.
Last edited by miguelp; Mar 5th, 2008 at 8:55 am.
![]() |
Other Threads in the PHP Forum
- Previous Thread: video to flash conversion
- Next Thread: Image in database
| Thread Tools | Search this Thread |
apache api array beginner beneath binary broadband broken button cakephp checkbox class cms code countingeverycharactersfromastring crack cron curl database date display dynamic echo email error fcc file files folder form forms freelancing function functions google href htaccess html image include incode insert integration ip javascript joomla limit link login mail match menu method mlm mod_rewrite multiple mysql oop pageing pagerank paypal pdf php problem query radio random recursion recursiveloop remote script search server sessions sms smtp soap source space sql strip_tags subversion support! survey syntax system table template tutorial undefined update upload url validator variable video virus web window.onbeforeunload=closeme; youtube






