i would like to check if there is anything in a variable, for my login script, i have tried
Code:
#!/perl/bin/perl
my $foo = "foo";
my $bar = "bar";
print "Content-type: text/html\n\n";
if ($foo =="" && $bar =="")
{
print "You have not entered a password/username!";
}
else
{
print "you would be logged in...";
}
but it doesn't work. Does anyone know how it can be done?
#!/perl/bin/perl
my $foo = "foo";
my $bar = "bar";
print "Content-type: text/html\n\n";
if ($foo eq "" && $bar eq "")
{
print "You have not entered a password/username!";
}
else
{
print "you would be logged in...";
}
the problem with that is, that if there is a user name but not a password, it doesn't tell you you've forgotten it. is there an 'or' that could be put instead of && ?
EDIT:
or can it be done with 2 if statements?
i have tried this code, but it didn't work, can you see the problem?
Code:
#!/perl/bin/perl
my $foo = "foo";
my $bar = "bar";
print "Content-type: text/html\n\n";
if ($foo eq "")
{
print "You have not entered a password/username!";
}
else
{
if ($bar eq "")
{
print "You have not entered a password/username!";
}
else
{
print "you would be redirected...";
}
};
EDIT 2:
After i got the eq's right i found out it works!
Thanks for the help!
Now i've got that bit done, instead of redirecting the user, it prints "Status: 302 Moved Location: "
My code is:
Code:
#!/perl/bin/perl
use CGI qw/:standard/;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
my $foo = param('foo2');
my $bar = param('bar2');
my $redirect = "http://".$foo.":".$bar."\@82.36.196.155/secure/";
print "Content-type: text/html\n\n";
if ($foo eq "")
{
print "You have not entered a password/username!";
}
else
{
if ($bar eq "")
{
print "You have not entered a password/username!";
}
else
{
print redirect($redirect);
}
};
You can't output data before sending a redirect request, if I'm not mistaken. Try...
Code:
#!/perl/bin/perl
use CGI qw/:standard/;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
my $foo = param('foo2');
my $bar = param('bar2');
my $redirect = "http://".$foo.":".$bar."\@82.36.196.155/secure/";
if ($foo eq "")
{
print "Content-type: text/html\n\n";
print "You have not entered a password/username!";
}
else
{
if ($bar eq "")
{
print "Content-type: text/html\n\n";
print "You have not entered a password/username!";
}
else
{
print redirect($redirect);
}
};
Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.
Bookmarks