PHP web page generator

Course- C IN LINUX >

The ability to write short programs in C to automate tedious tasks or to do things that would otherwise take hours of iddling about with cumbersome tools such as doing mail-merge, is one on the things you will be most pleased you have learned how to do. his project is such a time-saver. Ghost is a lightweight PHP generator for you to customise.

If you ind yourself having to build PHP web sites all the time, a quick way to generate all the parameterpassing, decoding, forms building and database management code in one step would be useful. Tools like Ruby on Rails ofer such functionality but are ininitely more complex to set up and run and you end up with needing to learn yet another language to go any further.

Probably the best way to start with this tool is to compile and run it. Unzip the ghost.zip source into your public_html folder which creates a folder called ghost. he Makeile contains a target g1 that compiles and links ghost. So go to public_html/ghost and type: make g1.

To run the site generator type:

  • - ./ghost testwebsite data1 data2 data1 data3 data4 data6 data6
  • - This will create:
  • - a folder public_html/testwebsite
  • - a mysql database table called testwebsite with text fields data1 data2 data1 data3 data4 data6 data6
  • - a testwebsite.css file
  • - empty header.html and footer.html pages
  • - index.php that demonstrates a form handling entry, edit & update, and delete to the database table for the data items specified.

In a browser what you see is this at http://localhost/~yourname/testwebsite

index.php that demonstrates a form handling entry, edit & update, and delete to the database table for the data items speciied

The idea behind this is that all the mechanical bits to create and manage the form content are done and can be customised. his screen shot shows the result of submitting one record. The top row is for entering new data, the lower row(s) allow editing or deleting of records. It is a framework that allows you to take and use parts in your own website design.

Let us examine this code in sections.

The first section declares the required data and creates the folder and CSS file.