in reply to cgi problem

here is your code fixed :)
#!\perl\bin\perl.exe -w use strict; use CGI qw(:all); my $cgi = new CGI; #usernames and passwords my %login = qw(antonis koukou giannis zabon); my $user = param("user"); my $pass = param("pass"); print $cgi->header. $cgi-> start_html(); if ($pass eq $login{$user} && $pass && $user) {#Add && $user && $pass print $cgi-> p("Welcome back $user"); }else { print $cgi-> p("Sorry invalid username or password"); } print $cgi->end_html;

Replies are listed 'Best First'.
Re: Re: cgi problem
by Anonymous Monk on Jan 04, 2003 at 14:23 UTC
    Which will fail if pass or username is equal to 0. Or 0000000.
      Problems are often solved with the simplest solution. Simply add an elsif statment. Hope this helps..
      E.g.
      if($whatever eq $whatever2) { #do whatever you wana do; } elsif ($what ever you want eq " "){ #Access Denied; } else{ #do whate ver you wana do here; }
      You get my point.
      All the best, Eoin...