#!/usr/local/bin/perl ########################################################################### #Process Sign-in screen #Introducing cookies (this Perl script stores cookies) ########################################################################### use CGI "param"; $lastname; $pswd; $name_pswd; $msg; if ( ! param() ) { # if there are NO input fields $first_time = 'yes'; # it must be first time around } else { # otherwise $first_time = 'no'; # it's not the first time around $lastname = param('lname'); # get form input for lname $pswd = param('passwd'); # get form input for passwd $name_pswd = $lastname.$pswd; # name_pswd = lastname + password &test_input(); # test the input fields } if ($first_time eq 'yes' || $msg ne '') { # if first time or there are errors &print_form(); # print the sign-in form } else { # if there are no error messages &print_menu(); # print menu } exit(0); ########################################################## sub test_input { if ($pswd eq '') { $msg = 'Please enter your password!'; } if ($lastname eq '') { $msg = 'Please enter your last name!'; } } ########################################################## sub print_form { print "Content-type: text/html \n"; print "\n"; print "
$msg
"; } ########################################################## sub print_menu { print "Content-type: text/html \n"; print "Set-Cookie: custid=$name_pswd; path=/"; print "; expires=Friday, 13-Apr-2001 23:59:59 GMT \n"; print "\n"; print "