Perl Login Script

JD Austin IV plug-discuss@lists.plug.phoenix.az.us
Mon, 11 Feb 2002 21:53:23 -0700 (MST)


> I tested this out, only friend/foe passes.  :
>
> #!/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 = undef;             # simply dealing with the hash so that
> it's more obvious
> $authusers{'friend'}='foe';   # $authusers{user}=password;
>
> $userid=$q->param('demid');
> $password=$q->param('dempwd');
> if ( $authusers{$userid} == $password and

DOH! the above line should be:
if ( $authusers{$userid} eq $password and

Sheesh.. 3 1/2 months away from perl coding and I let stupid things like
that slip by... :(


> (defined($authusers{$userid})) ) {
>
> print $q->header,                    # create the HTTP header
>       $q->start_html("Hello $userid" ), # start the HTML
>              $q->h1('You are authorized...'),         # level 1 header
>              $userid,  $q->end_html;                  # end the HTML --
> took out what didn't make sense
>              #I wasn't sure what you were trying to print above, so I
>              took
> all out except for the title and userid.
>
>                     }
>                     else
>                     {
>                     print $q->header,$q->start_html("else"),
>                     $q->h1('Failed...'),
>                     $q->end_html;
>                     }
>

-- 
There is no problem that can withstand the assault of sustained thought. ~
Voltaire
They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety~ Ben Franklin