Web servers, installed one: Apache. On silo, Unix. Apache directories: htdocs (HTML), cgi-bin, conf, logs, bin. Write programs for Apache: Perl, Python. Keeping state. Lab three: set up password protected folders. Use yours to post your homework assignments. Currently this means: Homework Two. Move on to new topics: MySQL and PHP. Install them. MySQL server allows for relational database design & management. PHP started as a CGI script written in Perl. It's a platform for programming like Perl/CGI or Python/CGI. PHP brings up the notion of server-side state (sessions). End the first half of the semester with an implementation of server-side state with Perl/CGI and a database. Database access from Perl also look into database access from Python and PHP. -- state, input, constant what is our state: a) changes but we need to remember it: the right answer b) changes but we need to remember: remaining flags c) changes but needs to be remembered: user's score d) changes but needs to be remembered: the question number what is our input: e) can't anticipate, read from user: the answer constants: f) the url: goes in the code, directly -- So the code ended up like this: #!/usr/bin/perl use CGI; $q = new CGI; @names = ("Italy", "China", "United States", "Australia", "Russia", "Brazil", "South Africa", "Spain"); $url = "http://silo.cs.indiana.edu:46016/images/"; print $q->header, $q->start_html; # retrieve state: $questions = $q->param('questions'); $answerkey = $q->param('answerkey'); $userscore = $q->param('userscore'); $totalques = $q->param('totalques'); # if state is empty: if (! $questions) { # initialize the state $userscore = 0; $totalques = 0; $answerkey = ""; $questions = join(',', @names); $message = "Are you ready? Score now: $userscore / $totalques "; } else { # otherwise: read the input, update the state $answer = $q->param('answer'); if ($answerkey) { # do grading, when appropriate } else { } @questions = split(/,/, $questions, 2); $answerkey = $questions[0]; $questions = $questions[1]; $message = "What flag is this: ?"; } print qq{
$message

Press when ready.

}; print $q->end_html;