#!/usr/bin/perl

use CGI qw(:standard);

@cookies=sort qw/peanut mint chocolate butter mm/;

# Recover the previous cookie order from the magic cookie.
# The cookie has been formatted as an associative array
# mapping cookie name to the number of cookies package ordered.
%orders = cookie('cookie_order');
$ID = cookie('ID');
#if there is no unique ID create one
if (length($ID) eq 0) {
	($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
	$ID = "CS401_$year\_$mon\_$mday:$hour:$min:$sec"; 
}

print header('text/html');
print start_html('cookie order');
print "The following order has been ";
if (param('action') eq 'cancel') {
	print "canceled. Please press the button for start another order.<BR>";
} else {
       print "confirmed and processed.  You should receive the cookie at the end of March. Thanks.<BR>";
}
      print hr,
      start_form("POST", "oc.pl");
print "Order#=$ID<br>";
print "<table BORDER=2>";
print "<tr><td><b>Cookie</b></td><td><b># of boxes</b></td></tr>";
foreach $cookie (@cookies) {
	print "<tr><td>$cookie</td><td align=right>$orders{$cookie}</td></tr>"; 
}
print "</table>", hr;
    print submit(-name=>"action", -value=>"Start Another Order");
    end_form;
print end_html;


