Spring Semester 2007


Lab Seven: Using DBI.pm to implement sessions in CGI with Perl
We assume your MySQL is installed.

Try these scripts (make sure they work) in your accounts:

It's OK if for the time being you make these work with my database.

Here's what tables I use:

mysql> describe dgerman_accumulator;
+------------+-----------+------+-----+-------------------+-------+
| Field      | Type      | Null | Key | Default           | Extra |
+------------+-----------+------+-----+-------------------+-------+
| session_id | char(8)   | NO   | PRI |                   |       |
| acc        | int(11)   | YES  |     | NULL              |       |
| modified   | timestamp | YES  |     | CURRENT_TIMESTAMP |       |
+------------+-----------+------+-----+-------------------+-------+
3 rows in set (0.00 sec)

mysql> describe dgerman_guessTheNumber;
+------------+--------------+------+-----+-------------------+-------+
| Field      | Type         | Null | Key | Default           | Extra |
+------------+--------------+------+-----+-------------------+-------+
| session_id | char(8)      | NO   | PRI |                   |       |
| message    | varchar(120) | YES  |     | NULL              |       |
| secret     | int(11)      | YES  |     | NULL              |       |
| attempts   | int(11)      | YES  |     | NULL              |       |
| won        | int(11)      | YES  |     | NULL              |       |
| lost       | int(11)      | YES  |     | NULL              |       |
| modified   | timestamp    | YES  |     | CURRENT_TIMESTAMP |       |
+------------+--------------+------+-----+-------------------+-------+
7 rows in set (0.00 sec)

mysql>
Now about the sample midterm.

Here's a working version of the program (see page 66 in the book).

Here's the code for:

I will demo them and discuss them in class.


Updated by Adrian German for A348/A548