Logo  

CS479/579 - Web Programming II

Description

Exercise #6

  1. Make sure you have webserver w/ PHP support and a database, such as MySQL or MariaDB, installed.

  2. Populate the config.php to connect to your database and create a $myconn resource handle to be used in the following two scripts. Do not put anything else in the config.php.

  3. Create a PHP script called newdb.php that would make queries to the database and (re)create a table called 'messages' that has the following columns:

Column Description
id An auto-incremented integer, which is also the primary key.
title A variable length string up to 100 characters, default of empty string
mesg A text field, default should be the empty string
date A timestamp, default should be CURRENT_TIMESTAMP()

The script output should also include a query to populate the message table with a default message.

NOTE: This script should use the PHP mysqli interface (as should the next script,) to create and populate the table. It should not just output SQL commands for the mysql client command.

  1. Create a script called mboard.php that should use the display the same kind of message board as with exercise 5 (refer to exercise 5 for more information,) however, this time using the database you created with newdb.php.

    The mboard.php should have a form that posts to itself in order to add another message to the message table.

    These scripts should use the PHP mysqli as described in lesson 6. You should use prepared statements whenever a query requires inputs. Do use htmlspecialchars() on all data strings received from the user.