Jump to content

DIV (or somthing) Work like textbox


POC0bob

Recommended Posts

Hello, this is a little complicated but I hope I can explain this well enough to get a good answer.

 

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

 

 

-POC0bob :)

Link to comment
Share on other sites

also, Use htmlspecialchars to convert HTML into displayable entities.

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.

 

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.