嗨,我对 perl 很陌生,我遇到了一个问题,即我的部分脚本被跳过了。
我正在尝试验证用户。如果用户输入 admin 和 admin 它会显示欢迎屏幕,否则会显示错误。
脚本不断跳过我的 if 条件。有任何想法吗?
#!/usr/bin/perl
use CGI;
use strict;
use warnings;
my $object = new CGI;
print "Content-type: text/html\n\n";
if ($object->param("submit")) {
validate_form ();
} else {
display_form ();
}
sub validate_form {
my $user = $object->param("user");
my $password = $object->param("password");
my $user2 = "admin";
my $password2 = "admin";
my $wrong = "WRONG";
if (my $user == my $user2 && $password == $password2) {
print $password;
} else {
print $wrong;
}
}
sub display_form {
print <<END_HTML;
<html>
<head>
<title>Assignment 1</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<form method="post" action="/~int322_132sa13/cgi-bin/assn1/test2.pl" enctype="mu
User Name: <input type="text" name="user" />
Password:<input type="password" name="password" />
<input type="submit" name="submit" value="submit" />
</form>
</body>
</html>
END_HTML
}