On Wed, 15 Jan 2003 15:54:02 +0800, [EMAIL PROTECTED] (Glynn S. Condez) wrote:
>i have a web form that users can input a username and password and check if >the username is valid by parsing or extracting the contents of a file, here >the web form html: I'm not sure what you are trying to do with just the username, don't you want to check the password too? >#!/usr/bin/perl >use CGI qw(param); > >$username = param('username'); >$password = param('password'); > >$file= "/home/user/public_html/file.txt"; >print "Content-type: text/plain\n\n"; >open (F1,"$file"); >foreach (<F1>) { >chomp; >($field1,$field2,$field3,$field4,$field5,$field6) = split /\s/, $_; > >if ($username =~ /\b$field2\b/) { if (($username =~ /\b$field2\b/)and ($password =~ /\b$field3\b/)) { print "OK\n"; print "$username and $password\n"; }else{ print "oops try again\n"; } } close(F1); > >and this is the content of the file.txt: >----snip---- user: user1 password my.domain.com mech:PLAIN >user: user2 realm: my.domain.com mech:PLAIN >user: user3 realm: my.domain.com mech:PLAIN >user: user4 realm: my.domain.com mech:PLAIN >---snip--- > >my problem with this script is, it doesnt display if the >username is valid or not but valid usernames display >OK, $username and $password. > >whats the problem with the else statement? kindly correct my >script. > >TIA >glen >--- Glynn --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]