FRIHOSTFORUMSSEARCHFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

neep help making email form that accepts html tags

 


ammonkc
I'm trying to make a simple email form in php that can accept html tags. But I'm having trouble with this. the html tags inserted into the form by the user screws up my php and html tags. this is the function that creates the headers and sends out the email.

Code:
function email($user_email) {
   $from = "email@domain.net";
   $headers = "From: $from\n";
   $headers .= "Content-type: text/html; charset=iso-8859-1";
   $msg_body = '<html><body><img src="http://mypage.net/images/image.jpg"><p>';
   $msg_body .= '<div style="border:grey 1px solid; margin:0 auto; width:500px; padding:15px; font-size:14px;">';
   $msg_body .= "<p>".nl2br(stripslashes($_REQUEST['messege']))."</p>";
   $msg_body .= "</div></p></body></html>";
   /****  send email out  ****/
   mail($user_email,$_REQUEST['subject'],$msg_body,$headers);
}//end email() function


This actaully works as expected with all html tags. but the problem that I'm having is that I need to display a preview of the messege before I send it. I'm saving the subject and messege body in a hidden form variable. then when the user hits 'send' on the preview page, it should send, but the form and the tags get screwed up here on the preview page. the problem is that I have tags inside the messege body text, and that is conflicting with the page tags. Is there any way to hold a string variable with html tags on this intermediate preview page without screwing everything else up?
Atomo64
Just use htmlentities with the string that has tags but you want to see them as plain text. E.g:
Code:

$msg_body="<html><body>Some content here...</body></html>";
if($_GET['preview'])
echo htmlentities($msg_body);
else
send_mail($msg_body);
ammonkc
Thats it. thanks. I knew that there was a simple way around that. I was about to try and make a bracket tag system like phpbb uses for formatting sections of text ([html] [/html]). that saves me tons of time. thanks
Related topics

ASP.NET 1.0 email form
email form handling on a windows 2000 server help.
asp.net email form
Anyone need some FRIH$ - for flash email form with PHP
Help with php email

Anyone know how to make an email form?
Web form to save HTML table as spreadsheet
Html Forms help please?
Create a Flash Contact form, sends to your email account
Reducing Exploits

Wordpess help needed.
Email Form
Help with php and java script
[OK] How to force the filling of a email form field ?
Email form script - 50 FRIH$
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.