I don't know if this is the correct forum for this topic but here goes.
I have an application where I want to use a form textarea to enter text, provide the ability to preview the text, similar to blogs, then email the completed message to multiple recipiants.
The problems come in when trying to handle HTML link code (<a href=""></a>) and hard returns. I have experimented a bit with the PHP function htmlspecialchars and have used the PHP mail function where returns must be specified as \n or \r\n.
My question is, does PHP have a function to replace hard returns with \n and is there a way to preserve HTML link code in the final email message or do I have to process the text myself? I would prefer not to implement blog-like capabilities.
Thanks for any help,
Bob
Text Formatting Functions
Moderator: General Moderators
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Text Formatting Functions
Will this option be available to only you, in the role of admin, or to users in general? If it is only you doing the entering of data, you can leave away the htmlspecialchars() / htmlentities() and add a 'Content-type: text/html' header to send the email as a link. That header will let the email be sent as an html document basically.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: Text Formatting Functions
Are you sending a plain text email or an HTML email? If plain text, then the hard returns in the textarea will translate to hard returns in the email. Additionally, you won't be able to put <a /> tags in your email & have them parsed.
If you're sending HTML emails, you'll want to look at the nl2br() function.
If you're sending HTML emails, you'll want to look at the nl2br() function.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.