Mazar Posted July 2, 2012 Share Posted July 2, 2012 Quick question, If I were to allow users to post content that could include html, and stored that data in a MySql database, then I would print it on the page eventually, is there a way I can contain their html inside a div so that it cannot affect any code outside of that div? Thanks,Andrew Link to comment Share on other sites More sharing options...
Guest So Called Posted July 3, 2012 Share Posted July 3, 2012 Have a look at these: http://php.net/manual/en/function.htmlspecialchars.phphttp://www.php.net/manual/en/function.htmlentities.php I'm pretty sure one or the other will solve the problem for you. Link to comment Share on other sites More sharing options...
Mazar Posted July 3, 2012 Author Share Posted July 3, 2012 Thanks, but I think you misinterpreted what I meant lol I want the html entities to work, but only within, say, a specified div. That is to say, if this were the code:<div class="user_input_sample"> <!-- user input start here --></div> this would mess with the outter html<b> ohai </b> <!-- this line should work (i.e. make it bold) --><!-- user input end here --> </div> So, what I want is so that it would allow users to use html to format their text (not ubbc), but a way to prevent it from affecting the html outside that specified div. The links you provided seemed to be more of a replace special chars thing. Link to comment Share on other sites More sharing options...
Guest So Called Posted July 3, 2012 Share Posted July 3, 2012 I think you'll have to parse your user HTML code. I dunno. Maybe an IFRAME might do it. The egg-spurts will have to chime in. Link to comment Share on other sites More sharing options...
Mazar Posted July 3, 2012 Author Share Posted July 3, 2012 Ooo, didn't think of an iframe... I will have to try that later, 'tis a good idea. Til then, eggspurts feel free Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now