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
- Use a single index.php file
- Display an input for a “Key” and a “Value”
- Display a Submit button
- Display a table of existing keys and values
- Submit button posts to the same php file
- 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
- That’s it!
Here’s a link to the source code:
https://github.com/bseaver/Demonstration-Projects/tree/master/mini/index.php
Here’s a link to the working site:
https://www.seaver99.com/demo/mini/
