Program password.pl #!/usr/local/bin/perl
#windows environment #Read in Parameter passed require "cgi-lib.pl"; &ReadParse (*input); $name_status =$input{'name'}; #Read User ID from HTML form $pass_status =$input{'pass'}; #Read User Password from HTML form #Open Password file sand store information into memory. open(PASSWORD,"password.dat"); $pass_count=0; while (!eof(PASSWORD)) { $name[$pass_count] = &get(PASSWORD); $pass[$pass_count] = &get(PASSWORD); $pass_count++; } close (PASSWORD); #Check Whether the user name and user password match with password file or not print "Content-type: text/html\n\n"; print " <html> <head> <title>Test(Perl)</title> </head> <body bgcolor='ffffff' text='000000'> <table>"; #Check password for($i=0; $i<$pass_count;$i++) { if ($name[i] = $name_status) { if ($pass[i] = $pass_status) { print " <BR><A HREF='/customer.html'>Add Customer</A> <BR><A HREF='/view.html'>View Customer details</A> " } else { print "Wrong user name"; } } else { print "Please enter name"; } } print " </body> </html>"; sub get { local ($handle)= $_[0]; local ($str)=""; local ($ch); while ($ch ne "\n") { $ch=getc($handle); $str=$str.$ch } return $str; } Dear all, Can anybody help me look script above, I¡¦m detected the script above has a bug I cannot solve. I assume have create a file call password.dat. This file I save 3 record like below: 0001 test 0002 halo 0003 Bye Actually I want this script to call the password.dat to verify my user id and password keyin is match with my password.dat. If everything is match the user allow to view the html form like I write above. The main problem is the looping cannot stop, and the script only check a single condition only. Mean if the user ID is correct, the visitor not need key in the password also can view my html page. I also detected my script sometime can work same time cannot work. May I know how to solve this problem? Any comment return will appreciate. Thanks