Perl Login Script

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Roderick
Date:  
Subject: Perl Login Script
What is wrong here... I need to validate an name=>password pair, from a
form submission.

script:
----------------------------------

#!/usr/local/bin/perl -w
# CGI script that creates a fill-out form
# and echoes back its values.
use CGI qw/:standard/;
$q=new CGI;                        # create new CGI object
%authusers = ('user','password','friend','foe');


if( $q->param('dempwd') == $authusers{$q->param('demid')} ) {

print $q->header,                    # create the HTTP header
       $q->start_html("Hello $1" ), # start the HTML
       $q->h1('You are authorized...'),         # level 1 header
    $authusers{$q->param('demid')},
    $q->param('name'),
       $q->end_html;                  # end the HTML


}
else
{
print $q->header,$q->start_html("else"),
    $q->h1('Failed...'),
    $q->end_html;
}


---------------------------------------
and here is the form submission...
---------------------------------------
<form name="login" method="post" action="logint.pl">
   <p> Demonstrator's ID
     <input type="text" name="demid">
   </p>
   <p>Password
     <input type="password" name="dempwd" size="20">
     <input type="submit" name="Login" value="Log In">
   </p>
</form>