limitphp Posted February 6, 2009 Share Posted February 6, 2009 On my site, I want people to be able to leave comments. I want the comments to show when they skip a line (hit enter), like this: test test2 But I also want to protect the comments from showing html. so if someone puts: <b>test</b> <b>test2</b> it will skip the lines, but it will expose the html and not bold the text.... How would I do that? Currently, I use: $value = htmlspecialchars($value, ENT_QUOTES); to protect against html, but that takes away the ability to have their comments skip lines. Link to comment https://forums.phpfreaks.com/topic/144115-solved-need-help-displaying-comments/ Share on other sites More sharing options...
landavia Posted February 6, 2009 Share Posted February 6, 2009 >>$value = htmlspecialchars($value, ENT_QUOTES); after above.. u add <?php $value = htmlspecialchars($value, ENT_QUOTES) $value=str_replace("\n","<br/>",$value); ?> Link to comment https://forums.phpfreaks.com/topic/144115-solved-need-help-displaying-comments/#findComment-756198 Share on other sites More sharing options...
limitphp Posted February 6, 2009 Author Share Posted February 6, 2009 I see....thank you. Maybe a better question for me to ask is, is there a Best Practice used to display comments? on edit: (not maybe, I know) there are other things that people use to display comments that I don't even know to think of? Link to comment https://forums.phpfreaks.com/topic/144115-solved-need-help-displaying-comments/#findComment-756200 Share on other sites More sharing options...
landavia Posted February 6, 2009 Share Posted February 6, 2009 well.. using txt is better but using DB is the best ^^ well.. i just reply someone else.. he/she use txt :o coll isn't but to split i add [br] and [eof] Link to comment https://forums.phpfreaks.com/topic/144115-solved-need-help-displaying-comments/#findComment-756209 Share on other sites More sharing options...
limitphp Posted February 6, 2009 Author Share Posted February 6, 2009 well.. using txt is better but using DB is the best ^^ well.. i just reply someone else.. he/she use txt :o coll isn't but to split i add [br] and [eof] I don't understand what you just said... What do you mean by txt, coll, and eof? Link to comment https://forums.phpfreaks.com/topic/144115-solved-need-help-displaying-comments/#findComment-756223 Share on other sites More sharing options...
landavia Posted February 7, 2009 Share Posted February 7, 2009 about comment u said above. where you want to put the comment? are u using DB (mysql) or just textfile (*.txt) ??? Link to comment https://forums.phpfreaks.com/topic/144115-solved-need-help-displaying-comments/#findComment-756469 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.