Jump to content


Dead-simple View/edit Script

  • Please log in to reply
1 reply to this topic

#1 lazytiger

  • New Members
  • Pip
  • Newbie
  • 1 posts
  • LocationChicago

Posted 28 June 2006 - 12:35 AM

I'm a PHP newbie, and I'm trying to roll my own simple webpage editor based on the following idea:

You have a webpage constructed with a template handling the common parts (header, footer, menu) and it calls in a separate file with the content. The content is called based on what is asked for in the URL, i.e., "whatever.com/intro" displays the template and pulls in a file called "intro". On this page is an "edit" link, which replaces the normal content with an editable text box containing the content. Hit "save" and you are taken back to the updated view-only content.

Simple enough, but I don't want to use a database. I've already cobbled together a simple CMS that pulls in content from MySQL, and it seems like overkill. Why not just store the content in plain old text files, one per page? I have not been able to find a tutorial DOESN'T use a database to do what I described above. It seems like it should be so simple that I'm getting extremely frustrated that I can't find an example script to learn from. I know enough PHP that I could make it work with a good example to start from, but I haven't a clue how to start it from scratch.

Obviously, this is highly insecure. The next step would be to wrap the editing into a logged-in session.

Please let me know if you know of any scripts that I could start from, or if you could give me a few clues about how to write it from scratch. Thank you!

#2 poirot

  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 28 June 2006 - 01:34 AM

[!--quoteo(post=388688:date=Jun 27 2006, 05:35 PM:name=lazytiger)--][div class=\'quotetop\']QUOTE(lazytiger @ Jun 27 2006, 05:35 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]I have not been able to find a tutorial DOESN'T use a database to do what I described above. [/quote]
You know, I had this problem before, and most of people just love MySQL for some reason and will resort to it for the simplest of the scripts.

But anyway, it's not hard to use flat files. I am used to:

1. Put these files in a folder, and have it secured with .htaccess (denying public access)
2. Use a combination of serializer and file handling functions to handle them.

[a href=\"http://www.php.net/serialize\" target=\"_blank\"]http://www.php.net/serialize[/a]
[a href=\"http://www.php.net/fopen\" target=\"_blank\"]http://www.php.net/fopen[/a]

I am a bit lazy to tell you the details; but I hope you can figure it out.
~ D Kuang

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users