#!C:/perl/bin/perl.exe use CGI::Carp qw(fatalsToBrowser); use CGI; $query = new CGI; $pin= $query->param('pin'); $password= $query->param('password'); $pass= $query->param('pass'); print $query->header; print $query->start_html(-title=>'Login'); print " \n\n"; #----------------------------------- # Check login status #----------------------------------- # Open the txt file containing the usernames and passwords and dump those data to # @passdata open(INFO, "$ENV{'DOCUMENT_ROOT'}/P593/data/userlist.txt"); @passdata = ; close(INFO); # Sort through each line of @passdata until we find a match between both the username and password # If a match is found, change the value of $match to 1. It is set to 0 by default. $match = 0; foreach $key (@passdata){ @a=split(/,/,$key); if($a[0] eq $pin && $a[1] eq $password){ $match=1; } } # If no match was found, provide an error msg. if($match !=1){ print "We cannot find a record of either that user name ($pin) or password.

"; print "If you think you may have made a typo, please click your browser's Back button and try again.

"; } # If the username/password match those stored on the master list on the server, # move forward and present the survey and do other things. if($match == 1){ $pass = $pass + 1; print "The study would appear here just like normal. The only difference is the code that checks the login status. In addition, if the survey involves multiple pages, the \$pin and \$password must be passed forward on each page in hidden tags. Otherwise, the user will be blocked from the site as soon as he or she presses submit the first time. The data would be saved as the last step and then the user would be taken to a 'thank you' page.

"; print "
Here is question number $pass

"; print ""; print ""; print ""; print ""; print "
"; } # end match == 1