From: "zentara" <[EMAIL PROTECTED]>

Hi it works now but why is it that it prints a lot of results and it seems
that it reads the
file line by line and do the output. Sorry i forgot to mention that the file
contains duplicate entries
of username, it something like:

----snip----
user: user1 realm: my.domain.com mech:PLAIN
user: user2 realm: my.domain.com mech:PLAIN
user: user1 realm: my.domain.com mech: DIGEST-MD5
user: user3 realm: my.domain.com mech:PLAIN
user: user2 realm: my.domain.com mech:DIGEST-MD5
---snip---

so if the file contents 10 lines of entries it display 10 lines of output,
here's the real output

if match is found, browser prints:
oppss try again
OK, user1 found
oppss try again
oppss try again
OK, user1 found
oppss try again
oppss try again
oppss try again
oppss try again
oppss try again

if no match found, browser prints:
oppss try again
oppss try again
oppss try again
oppss try again
oppss try again
oppss try again
oppss try again
oppss try again
oppss try again
oppss try again

Is it possible not to display all the entry that match and doesn't match,
just only print OK, user1 found and opps try again?

what should be added or changed on the code?

TIA
glen







> 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]
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to