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

Due on Thursday March 20 before midnight


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.

This project must be done individually. No copying is permitted. Note: We will use a system for detecting software plagiarism, called Moss, which is an automatic system for determining the similarity of programs. That is, your program will be compared with the programs of the other students in class as well as with the programs submitted in previous years.

Note that, if you use a Search Engine to find similar programs on the web, we will find these programs too. So don't do it because you will get caught and you will get an F in the course (this is cheating). Don't look for code to use for your project on the web or from other students (current or past). Just do your project alone using the help given in this project description and from your instructor only.


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 using SSH and do the following:

cd public_html
tar xfz project5.tgz
cp project4/.htaccess project4/.htpasswd project5/
cd project5
The project5 directory contains the file createDB.sql, which contains the SQL description of 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
Foreign key: posts.postedby->users.username
An empty sqlite database has already been created for you, called mydb.sqlite. An example of an sqlite session on omega is:
sqlite3 mydb.sqlite
select * from users;

The project5 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.


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.
Note that when there is an error (eg, username already exists), you go back to Page1.

For each posted message, you print:

The messages must be printed ordered by date/time (oldest first).

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 a comment on top of your board.php file, put your name, your student ID, and your URL address to run your web application, such as Use the form below to submit your PHP file(s). 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 #5:

Last modified: 03/05/14 by Leonidas Fegaras