CodeIgniter Forums
Storing HTML in MySQL - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Storing HTML in MySQL (/showthread.php?tid=11138)



Storing HTML in MySQL - El Forum - 08-27-2008

[eluser]codelearn[/eluser]
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?

Thanks!


Storing HTML in MySQL - El Forum - 08-27-2008

[eluser]ehicks727[/eluser]
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.


Storing HTML in MySQL - El Forum - 08-27-2008

[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.


Storing HTML in MySQL - El Forum - 08-27-2008

[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.


Storing HTML in MySQL - El Forum - 08-28-2008

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

My question is specifically how to validate HTML code.


Storing HTML in MySQL - El Forum - 08-28-2008

[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:

http://twineproject.sourceforge.net/doc/phphtml.html