A mini Data Driven site in PHP and MySQL

I’ve been investigating some DevOps techniques – and for testing needed a website that Created, Updated, Deleted and Displayed data. I decided to write a minimal sample website.

Here’s the design:

Mini Data Driven Website

  1. Use a single index.php file
  2. Display an input for a “Key” and a “Value”
  3. Display a Submit button
  4. Display a table of existing keys and values
  5. Submit button posts to the same php file
  6. Index.php does the following before returning any text
    • Login to database
    • Retrieve posted key and value data
    • Special case: if key=”drop” and value=”table”, drop the table and exit
    • Create the empty key value table if it does not already exist
    • If key is supplied and value is not empty, check for pre-existence of key and either update the corresponding value or insert the key value pair
    • If key is supplied but value is empty delete matching key value pair
  7. That’s it!

Here’s a link to the source code:

Here’s a link to the working site:

Leave a Reply