phpcontent-management-systemcontent-management

Use php to save text box content to a page


Im trying to build a extremely basic content management system. I want to do it all with php and was hoping it would be as simple as echoing content that was submitted in a text form.

The problem is I need to save the echoed content to the page somehow (preferably without a database) and then have it replaced with new echoed content if it is submitted. How would I save the content to the page?

Thanks in advance.


Solution

  • If you're dead set against using a database, the absolutely most basic thing you could do would be to save the contents to a file using file_put_contents(). You could reload it using file_get_contents(). Please be aware, though that you may be exposing yourself to various security exploits such as cross site scripting attacks and code injection attacks. Also, you may run into concurrency issues with one user wiping out another user's edits. You may also run into file permissions issues. If your site gets a lot of traffic, you might run into scalability and performance issues. As you start to research these issues, you'll start to appreciate why things quickly get more complicated than you initially want them to be.