CS637 Homework 1 SQL review, HTTP, HTML5 part 1, mysql, php, setup

Due Monday, Sept. 17 in class, on paper. Be sure to get a UNIX/Linux account for cs637 by Monday, Sept. 10, to list your username for the needed mysql account, and access to topcat.cs.umb.edu.

1. a. Basic HTML and URLs: if you really know HTML, you can skip part a. of this problem. Just state so on your homework submission. Read Chap. 1-3 of Duckett for basic HTML. Learn about absolute and relative URLs, by reading Chap. 4 of Duckett and looking at the examples in Murach & Harris (M&H), pg. 29 (either edition) For more practice (optional), go through the HTML tutorial at http://www.w3schools.com/html/ through "HTML Lists". Use a plain editor to compose a web page test1.html with page title "My title", contents entitled "Important links", and a relative link to a copy of this file (hw1.html), also in the same directory on the server, and an absolute link to the root of our departmental website, with appropriate descriptive text for the user to see.  Include the text of test1.html in your homework submission.

b. HTTP. Since hw1.html is in directory cs637 of our webserver's document root, its URL is http://www.cs.umb.edu/cs637/hw1.html, as you can verify by browsing to to this URL in your browser. Show the HTTP GET request and response, to the level of detail of the example shown on pg. 7 of M&H and also on slide 15 for the first class. Our server is Apache/2.4.18.

2. Review SQL. Read M&H Chap. 18. Go to sqlzoo.net,  Pull down the Tutorials menu, and select the following tutorials:

Show your answers (copy and paste the SQL query). If an error message seems useless, try another database for the query--it might give better error messages.

3 MySQL. Within a week, user ronghui, for example, will have an account on mysql on topcat with username ronghui, password ronghui, and a database named ronghuidb.  To access it, login to topcat and use the command:

mysql -u ronghui -D ronghuidb -p

and enter ronghui at the password prompt.  Another way is shown on pg. 111 of M&H:

mysql -u ronghui -p
Enter password: ronghui

use ronghuidb

Verify your mysql account is working by logging in to system topcat.cs.umb.edu and using the mysql command. See Access to cs.umb.edu systems from offsite for instructions on logging in from offsite.

a. Create a table named t1 with columns "id", and integer, and "message", a varchar(40). Insert 2 rows into it and then display the rows.  Show a script of this session in your homework. To make a script, type script at the Linux prompt before using the mysql command, then do the database work, exit from mysql, and do another exit to finish the script.

b. Note that the book applications are available at http://topcat.cs.umb.edu/book_apps on the web and since the web server document root is at /var/www/html on topcat, they are available in the topcat filesystem at /var/www/html/book_apps. Copy the SQL script my_guitar_shop1.sql from the _create_db subdirectory to your cs637/hw1 homework directory on topcat. Try to load your mysql database on topcat with this script and report on your success or problems.  Note: You will need to edit out the create database and create user commands from my_guitar_shop1.sql, as you have access only to your own database, and no privileges to create additional users.

4. a. Until students have XAMPP installed, we'll use topcat for simple PHP execution from the command line.  Code up the future value for loop of pg. 77 (either edition) in a complete php program future_value.php and execute it from the command line: topcat$ php future_value.php. Create directory hw1 in your cs637 directory and put future_value.php in it, making it have path ~/cs637/hw1/future_value.php. The original code is available in book_apps/ch02_future_value/display_results.php. If necessary (2nd ed), replace "$future_value =" with "$future_value += ..." that calculates the same amounts. Note that your program should have no HTML in it, since there is no browser involved here. Use echo to print the answer. Show your program in your homework paper and report your success or problems running it.

b. Run the future value example as a web application by browsing to http://topcat.cs.umb.edu/book_apps/ch02_future_value/. Try out valid values and invalid values as shown on pg. 81(either edition). Note that if some of the fields are valid and others invalid, the form is redisplayed with the valid values filled in. Users hate to loose valid input!  Make the app display a different error message, and explain what you did to make it happen.

5. Report on your DevelopmentSetup progress and/or problems.