You need to use the CGI script:

use CGI;
my $cgi = new CGI;
my $username = $cgi->param('username');
my $password = $cgi->param('password');

Teddy,
Teddy's Center: http://teddy.fcc.ro/
Email: [EMAIL PROTECTED]

----- Original Message -----
From: "Glynn S. Condez" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, January 15, 2003 9:54 AM
Subject: newbie need help


Hi all,

in new in perl language and i need help how to make my first cgi-perl script
work.
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:

<HTML>
<BODY>
<FORM METHOD="POST" ACTION="/cgi-bin/perl.pl">
<PRE>
Username<INPUT TYPE="text" NAME="username" MAXLENGTH=15 SIZE=15>
Password<INPUT TYPE="password" NAME="password"  MAXLENGTH=20 SIZE=20>·
<INPUT TYPE="submit" VALUE="Send Mail!">
<INPUT TYPE="reset" value=" Clear-Form">
</PRE>
</FORM>
</BODY>
</HTML>

my perl.pl script:

#!/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/) {
    print "OK\n";
    print "$username and $password\n";
}
else {
      unless ($username |~ /\b$field2\b/) {
      print "oppss try again\n";
   }
}
}
close(F1);

and this is the content of the file.txt:
----snip----
user: user1 realm: 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