Simple RTE which can be used with PHP / mySQL?

Hi, I’ve set up a job management system in PHP with MySQL db with some forms for adding / editing jobs and projects. However the client has now said that they want the ability to make formatting changes to the text that they type into a textarea field in the forms- for example, change color, make bold and so on. Then, after they save that record, when they view it later they want to be able to see the formatting changes, so they need to be saved into the MySQL db somehow.

I’ve had a look through text editors such as TinyMCE etc. but they all seem a bit of an overkill and not easy to add into a custom system like this which doesn’t have an inbuilt CMS. Is there any way I can add just a few buttons or functions to the textarea in the PHP form, so that the text can be made bold, have color changed or other basic changes? The formatting would need to be saved into the MySQL db record and would then be visible to the users when they open up the record again.

Any ideas how I can go about this? Thanks!

Textarea doesn’t support rich text. Those WYSIWYG editors you’re talking about use div with contenteditable="true" attribute set, instead of textarea:

<div contenteditable="true">This content will be editable</div>

And when you edit content in the div, editor puts its HTML code (as plain text with tags) into hidden textarea. You receive value of that hidden textarea when user submits form.

Google for “lightweight wysiwyg editor”. There are lots of them.
To integrate any of those editors (including monsters like TinyMCE) you usually have to just include its JS file to the page and run single line of JS code to replace your textarea with editor.

No, it’s quite easy. Here is how you add TinyMCE:

<textarea>This textarea will be replaced with TinyMCE</textarea>
<script src="//"></script>

Just 2 lines

Thanks, I set that up on a test page, unfortunately it doesn’t seem to have the ability to let the user change font color?

It’s better to ask documentation about that sort of things

Seems like this is what you want:

<script>tinymce.init({selector:'textarea', plugins:'textcolor', toolbar:'forecolor backcolor'});</script>
1 Like

Ok- that’s about perfect. Should work fine. Thanks!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.