Case 5 Model-View-Control Implementation
Model
My current setup for a model can be seen on my Case 3 page, but if you don’t feel like clicking on the link, I can go ahead and give a brief description to help with a mental visualization. I have named my database comments which will consist of five columns. The first is ID, which will be assigned to each entry. The next is name. The name will contain whatever name someone writes into the field. The third is the user’s email address the column will be called email. The fourth contains a subject, in other words, a short description about what the comment will discuss, it'll be called subject. The last column is comment, which will contain the comment that the user types.
The table will look like so:
| Field | Type | Size | Constraint | Extra |
|---|---|---|---|---|
| id | int | 4 | Primary Key | Auto Increment |
| name | varchar | 40 | - | - |
| varchar | 60 | - | - | |
| subject | varchar | 100 | - | - |
| comment | varchar | 400 | - | - |
View
Control
- Open the addcomments page.
- User enters values for each field (name, email, subject, and comment).
- User then presses the submit button.
- The page will then validate to make sure all fields are filled and are not null.
- If validation passes, then values will be entered into a new row being assigned with an ID and being stamped with a timestamp into the database.
- User will then be redirected to index.php with a comment being displayed that the comment was added.