Programming Assignment 6
Implementation of a Message Board using PHP and a Database

Due on Tuesday November 19 before midnight
Worth 6% of your final grade

Description

This project must be done individually. No copying is permitted. The goal of this project is to learn server-side web programming using PHP and a relational database system (SQLite). More specifically, you will create a message board where registered users can post messages.

Platform

As in the previous projects, you will develop this project on the Omega web server and you will test the project on your PC/laptop using the Mozilla Firefox web browser. Login at omega.uta.edu using SSH and do the following:

cd public_html
wget http://lambda.uta.edu/cse4392/project6.tgz
tar xfz project6.tgz
cp project5/.htaccess project5/.htpasswd project6/
cd project6
The project6 directory contains the file createDB.sql, which contains the SQL statements to create the tables: users and posts, that have the following schema:
users ( username, password, fullname, email )
posts ( id, postedby, datetime, message )
Primary keys: users.username and posts.id
Foreign key: posts.postedby->users.username
You may change this database schema if you like. To create the database, you do:
sqlite3 /tmp/xyz1234.sqlite
.read createDB.sql
.exit
chmod o+w /tmp/xyz1234.sqlite
(change xyz1234 to be your own username).
Note: if you get an error "SQL error: attempt to write a readonly database" when you create your database using the createDB.sql script, this means that you have already created this database under the username apache, possibly because you have run your PHP script before you created the database. In that case, use a different filename in the /tmp/ directory.

The project6 directory also contains the file board.php, which needs to be changed as described in the description of the web application. The board.php file uses the PDO extension of PHP to insert a new user and to query the users table using SQLite. Note: you need to change the $username in board.php to be your own username.

Documentation

The following are tutorials on PDO and SQLite. Use them as a reference only.

Project Requirements

Your script board.php must be able to produce 3 kinds of web pages:

  1. Page1: a login form that has text windows for username and password, a "Login" button, and a "New users must register here" button
  2. Page2: a "Logout" button, the printout of all messages ordered by datetime, and a message textarea with a "Post" button
  3. Page3: a form to fill out user information along with a "Submit" button
When board.php is executed for the first time, it displays Page1: From Page3, after the user pushes "Submit", it should go to Page1.
From Page2, if the user pushes "Logout", it should logout and go to Page1.
From Page2, if the user fills out the textarea and the "Post" button, it will insert the new message in the database and redisplay Page2

For each posted message, you print:

Hints: Use md5 to encode passwords in PHP. Use uniqid to generate a unique id in PHP. Use the SQLite function datetime('now') to compute the current date and time.

What to Submit

Important: In the comment on top of your board.php file, put the URL address to run your web application, such as http://omega.uta.edu/~xyz1234/project6/board.php. Use the form below to submit your PHP files. We do not accept email or hardcopy submissions. You may submit your files as many times as you like, but only the most recently submitted files will be retained and evaluated (newly submitted files replace the old files under the same file name). After you submit the files, please double-check that your submitted files are correct by clicking on the Status link.

Submit Project #6:

Last modified: 11/07/13 by Leonidas Fegaras