Main Content

A PHP example that lets your users edit content without HTML knowledge

Archive - Originally posted on "The Horse's Mouth" - 2010-02-14 08:00:44 - Graham Ellis

Scenario one. I need a "todo" list page for our web site which I, and the rest of our team, can view and update quickly and easily.

Scenario two. Dave wants to provide his local cricket club's website with pages that the committee can update without them having to be trained / skilled in HTML, with each of the pages having the same look and feel, and without the risk of something silly being inserted into the page that will cause a major security breach.

Dave was with me for last week's PHP Course and we wrote a single page wiki demonstration ... which I have just modified and installed onto our live web server as a staff usage page for our team.

When any of our team visits the page, this is the sort of thing we'll see - there are a few standard headers and timestamps, and a picture which can be changed by anyone who edits the page.


Select the edit button, and our staff members are offered a text edit window, and Javascript buttons for bold, italic, underline, colour changes, links, etc. These add in bulletin board type codes such as [b]through[/b] for bold.


With the particular case of our internal "todo" list, the display that's shown to public visitors isn't the one that I started with, but rather it's what you see here. We have chosen to display the picture, but only a standard piece of text that suggests you should be logged in.


The Wiki demonstration code - it's only about 6k bytes - is [here] and there's a sample template [here]. That's even shorter. You'll need to rewrite URLs so that all your page names point to a single script if you're going to be using multiple pages within the system - we have a sample .htaccess file [here].

If you're already knowledgeable in PHP, you should find the script quite easy, but if you'ld like some help with this and many similar things, we cover it on our PHP Techniques Workshop.