Hi. This bit of code is really getting on my nerves. Basically, what it is going to do is check to see if the username and password the enter exists. However, for some reason the && part (in bold) is nt matching. I added loads of debugging info to it BTW earlier t try and narrow down why the login thing wasnt working. The code is;
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
print "Content-type: text/html \n\n";
$input = new CGI;
$action = $input->param('action');
if ($action eq "login") {
# get the params
$password = $input->param('password');
$username = $input->param('username');
if ($password eq "") { &error("You need to specify a password!"); }
if ($username eq "") { &error("You need to specify a username!"); }
open (LIST, "/home/ace-clipart.com/passwords.list") || &error("Unable to open password.list...reason: $!");
flock(LIST,2);
@input = <LIST>;
close(LIST);
# search the file for a username
foreach $line (@input) {
print "$line <BR>";
if ($line =~ /$username\:\:+/) {
($ausername, $apassword) = split(/::/, $line);
print "$username & $password <BR>";
print "$ausername & $apassword <BR>";
if ($username eq $ausername && $apassword eq $password) { print "password ok..logged in"; last; } else { &error("Unable to login. Wrong password!"); }
} # end the regex if
} # end the foreach
} else { print "no info sent"; }
# an error sub incase something goes wrong.
sub error {
my $error = shift;
print $error;
exit;
}
It is probably something really silly, but I cant for the life of me see it
Anyone a bit more awake than me?
Thanks
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Code:
#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
print "Content-type: text/html \n\n";
$input = new CGI;
$action = $input->param('action');
if ($action eq "login") {
# get the params
$password = $input->param('password');
$username = $input->param('username');
if ($password eq "") { &error("You need to specify a password!"); }
if ($username eq "") { &error("You need to specify a username!"); }
open (LIST, "/home/ace-clipart.com/passwords.list") || &error("Unable to open password.list...reason: $!");
flock(LIST,2);
@input = <LIST>;
close(LIST);
# search the file for a username
foreach $line (@input) {
print "$line <BR>";
if ($line =~ /$username\:\:+/) {
($ausername, $apassword) = split(/::/, $line);
print "$username & $password <BR>";
print "$ausername & $apassword <BR>";
if ($username eq $ausername && $apassword eq $password) { print "password ok..logged in"; last; } else { &error("Unable to login. Wrong password!"); }
} # end the regex if
} # end the foreach
} else { print "no info sent"; }
# an error sub incase something goes wrong.
sub error {
my $error = shift;
print $error;
exit;
}
It is probably something really silly, but I cant for the life of me see it
Anyone a bit more awake than me?
Thanks
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!