For this assignment you will be creating a PHP script that allows you to interact with a MySql database. You will have to write SQL commands to insert elements and retrieve data from a single database table.
This assignment requires the use of data fields similar to those used in Lab 3, so it might be possible to reuse some code from your solution to that lab. You may find it useful to look at the example code demonstrated in the class lecture:
For this lab, you are to write a simple Web application with the following functionality.
When the user first comes to your page, she should be presented with a form to enter a username and three favorite urls. Once entered the user needs to be directed to a page containing a table that has all the usernames entered in the first columns and each url in the following columns. The table rows should be sorted alphabetically by the username. Also there should be a link somewhere on this page to allow the user to return to the form page so additional names may be entered. Solutions having both the list and input form on the same page will also be acceptable.
Instruction for testing connections to the database can be found here. The server name that you need to connect to is dav.cse.ucsc.edu and the database name is cmps183. Note that this is a MySQL database, and hence the information in Chapters 7-11 of the course textbook is applicable to this database. The username and password will be given in class and in lab; send email to the instructor or the TA if you need this information.
Each of you will has your own table pregenerated for use in the assignment. Its name is in the form sasha_lab4 where you will replace sasha with your own CATS user id. The columns for the tables are as follows:
username char(32) not null primary key, url1 char(64), url2 char(64), url3 char(64)
You need not worry about specific error handling for cases of duplicate or null user names, but it should be expected that such attempts will not be successful in writing to the database.
For submission please email Sasha [at] cse [dot] ucsc [dot] edu your PHP script and a URL to the script on a working webserver such as your user directory on the people.ucsc.edu servers.
Last modified: