Reputation: 117
I have simple sign in page. when i enter abc and 123 as login credentials it should redirect me to login successful page but it keeps giving me the internal error.If login information is not abc and 123 it should redirect to wrong login page. Maybe my if statement is wrong. Can you check my code out? Please.
#!/usr/bin/perl
use CGI qw( :standard );
$user = param( "user" );
$password = param( "password" );
$user = param( "user" );
$password = param( "password" );
if ($user == "abc") && ($password == "123")
print redirect ( "../../login.htm" );
}
if (!$user ne "abc") || (!$password ne "123")
print redirect ( "../../wrong.htm" );
}
Upvotes: 0
Views: 49
Reputation: 69314
I put your code into a file called test.cgi and then checked it for compilation errors.
$ perl -c test.cgi
syntax error at test.cgi line 11, near ") &&"
Unmatched right curly bracket at test.cgi line 13, at end of line
Unmatched right curly bracket at test.cgi line 17, at end of line
test.cgi had compilation errors.
So that gives you some places to look. The syntax you're using for your if
statements is broken in a couple of ways.
Here are a few suggestions that will help you write Perl code more efficiently.
use strict
and use warnings
to your code and fix the problems that they show you. There is at least one other problem in your code that will be found by use warnings
.Finally, writing a CGI program is not the best way to write a web application in 2015. Please look at some alternatives.
Upvotes: 1