Welcome Guest, Not a member yet? Register   Sign In
Storing HTML in MySQL

Hey guys,

Have any of you encountered a need to store html in your database. I am tasked with using a wysiwig editor and then saving this information in the database. Once a user accesses a certain page, I need to output the previously stored HTML.

Best way to do this, with or without TinyMCE?


This is very common, actually. I have used FCKEditor, mainly. I like it because it allowed me to specify what tags I want to allow.

You still have to check the text before you store it. In my most recent system I'm building, I'm stripping out everything except H, P, A, B, Strong, I, and EM tags. There are CI and PHP functions that are useful in stripping out illegal chars... you can use all sorts of regex checks as well.

I haven't used TinyMCE, but I would guess it's similar to FCKEditor. So to answer your question.... why not use both? An editor AND backend processing. You can't be too safe.

While you're at it, either use authentication, or a CAPTCHA to stop the form spammers.

[eluser]Phil Sturgeon[/eluser]
I have done a lot of work with TinyMCE and find it to be over engineered and slighly buggy. It could just be because we're using an old version which im not allowed to upgrade, but im still not much of a fan.

Worth a try is Spaw which is a very simple and looks brilliant.

[eluser]Eric Cope[/eluser]
I use TinyMCE. I also validate using the validation class. I am confused by your question. What is it that you are asking?
Is TinyMCE a decent wysiwyg editor? - sure, preferences may steer you to other editors, but you should be able to use it.
Is TinyMCE a decent way to validate the code? I doubt it. You should always validate it on the server.

If those aren't your questions, please reply and clarify.

[quote author="Eric Cope" date="1219884328"]Clarify question/quote]

My question is specifically how to validate HTML code.

[eluser]Eric Cope[/eluser]
Are you looking to validate all HTML code, or a small subset? If its only a small subset, then a preg_match statement for each tag may be sufficient. You could always integrate an external class like this:


Theme © iAndrew 2016 - Forum software by © MyBB