Hi I am trying to write a simplie login perl script all is working apart from the final if statement. if the username and password match the data stored in the txt file $auth returns true which works then a second if checks if £name is != to "admin" if true should be directed to order page if false should go to admin page but when I run it, if the username & password are correct it always goes to the admin page regardless of the username being != to "admin" would really appreciate some help here as I really cant see why have even put a print"$name"; just to check what its value is and its not "admin"
#!"\xampplite\perl\bin\perl.exe"
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
print "Content-type:text/html\n\n";
$auth = 0;
$name = param('username');
$pass = param('password');
open(LOGDATA,"login.txt") or dienice("Couldn't open Data File for reading: $!\n");
#set a shared lock
flock(LOGDATA,0);
#then seek the beginning of the file
seek(LOGDATA,0,0);
@raw_data = <LOGDATA>;
close(LOGDATA);
print "<html><head><title>results</title></head>\n";
print "<body>\n";
foreach $line(@raw_data)
{
chomp ($line);
($user, $word) = split(",",$line);
if ($user == $name && $pass == $word)
{
$auth = 1;
}
}
if ($auth == 1)
{
if ($name != "admin")
{
$usermenu = "AssiP1/order.htm";
}
else
{
$usermenu = "AssiP1/admin1.htm";
}
}
else
{
$usermenu = "AssiP1/loginfail.htm";
}
print "<html><head><title>results</title></head>\n";
print "<meta http-equiv=\"Refresh\" content=\"5;URL=//localhost/$usermenu\">\n";
print "<body>\n";
print "$name";
print "<body>\n";
sub dienice
{
my($msg) = @_;
print "<h2>Error</h2>\n";
print $msg;
exit;
}
Again any help would be great
Thanks
Niall