DIV (or somthing) Work like textbox
Posted 16 January 2013 - 01:09 AM
So, what I need is a div, or something to display text like a text box, including all the spaces and enters and things that would normally show up in a text box, but still work with HTML code, like links and things, and display those correctly. I am creating a user message system that has some basic HTML features, such as links and stuff, but when I use it as a div, its all on one line and stuff.. Also, another side note, is there a way to protect me from other users putting HTML code in the messages, and it running when they view the mail? All I want it to do is display the HTML code the functions generate before the message is loaded to the client. (PHP) If you have any other questions, please ask. Thanks
Posted 16 January 2013 - 08:04 AM
How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq
Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!
Posted 16 January 2013 - 01:49 PM
And I would follow that up with nl2br() to convert line breaks to <br> tags. Just be sure to do that after htmlspecialchars or else you will conver the br tags to textual content.
also, Use htmlspecialchars() to convert HTML into displayable entities.
EDIT: You did state you wanted to preserve 'spaces'. In which case PRE, as Kicken suggested, is the way to go. And if you do implement that, then you do not want to use nl2br().
Basically, there are several solutions and each has things it can and can't do. You'll need to determine exactly what you want to implement the best solution.
Edited by Psycho, 16 January 2013 - 01:51 PM.
I do not always test the code I provide, so there may be some syntax errors. In 99% of all cases I found the solution to your problem here: http://www.php.net
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users