how to create an wysiwyg html editor in <textarea name="sender_message"></textarea> is it possible when send an email from a php form?

Recommended Answers

Can you give a little more detail?

I'm not sure if you're wanting to fill in an HTML email with data from a form, or use a field in a form to create an HTML document, or use some kind of drag and drop HTML editor.

You could …

Jump to Post

All 4 Replies

Can you give a little more detail?

I'm not sure if you're wanting to fill in an HTML email with data from a form, or use a field in a form to create an HTML document, or use some kind of drag and drop HTML editor.

You could do something like:
(thisfile.php)

<!-- put your own header stuff above this line, use your imagination -->
<body>
<?php
if (isset($_POST['submit']))
 {
 echo $_POST['sender_message'];
 }
if (isset($_POST['post']))
 {
 // put your email code here.
 }
?>
<hr /><hr />
<form action='thisfile.php' method='post'>
<textarea name="sender_message">$message</textarea>
<input type='submit' name='submit' value="View" />
<input type='submit' name='post' value="Post Email" />
</body>

I don't know, anyone else have a better solution?

David

Oops, I forgot a major part of that.

In order to send HTML as email you have to put some additional info in your email headers.

$headers = "From: no-reply@placelogo.com \r\n";  // replace with your email address
  $headers .= "Reply-To: no-reply@placelogo.com \r\n";
  $headers .= "MIME-Version: 1.0 \r\n";
  $headers .= "Content-Type: text/html; charset=ISO-8859-1 \r\n";
  $emailto = "addressee@whereever.com";            // replace with the addressee
  $subject = "Subject of email";                   // replace with the subject line
  mail($emailto,$subject,$message,$headers);

David

Wrong:

<textarea name="sender_message">$message</textarea>

Right:

<textarea name="sender_message"><?php echo $message; ?></textarea>

thanks David its help me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.