In your validate function, it should be
the_form.password.value.length
For cookie, why don't you use CGI::Cookie instead for clean and easy handling.
Suggestion for your HTML printing:
print <<EOT
<HTML>
<HEAD><TITLE>View Your Subscriptions Login</TITLE>
<SCRIPT LANGUAGE="JavaScript">
blah blah blah ...
EOT
Easier to read and you can omit all the \ backslashes.
Jing Wee
At 04:29 PM 7/28/2002 -0500, you wrote:
Hi,
I have entered the valid userid and password, Still I am getting the error
message as "Password field can not be blank"? Can you suggest what could be the
reason?
This one is Web applications using the CGI technologies. This error is
happening before calling the next program "loginconfirm.pl". How to print the
value in @pair?
#!F:\perl\bin\perl.exe
use CGI qw(:standard escapeHTML);
# Get the user name from the previous html doc.
@rawcookies=split(/; /,$ENV{'HTTP_COOKIE'});
local(%cookies);
my $cookie_present = "0";
foreach (@rawcookies) {
$temp = $_;
($key, $val) = split(/=/,$temp);
($blah,$val) = split(/$key=/,$temp);
$cookies{$key} = $val;
}
# Read the data section and get all the parameters
while (<DATA>) {
chomp; # no newline
s/#.*//; # no comments
s/^\s+//; # no leading white
s/\s+$//; # no trailing white
next unless length; # anything left?
my ($key, $value) = split(/\s*=\s*/, $_, 2);
$ldParams{$key} = $value;
};
if ($cookie_present ne "1") {
# Now let's generate a web page to display the data we've got.
my @pairs = split(/&/, $ENV{'QUERY_STRING'});
print "Content-Type: text/html\n\n",
"<HTML>\n",
"<HEAD><TITLE>View Your Subscriptions Login</TITLE>\n";
&print_header;
print "<SCRIPT LANGUAGE=\"JavaScript\">\n";
print "function entrevous(keypressed) {\n";
print "// The Docment Object Model event we need is only available inf Javascript 1.2, MSIE4+ and NN4+ \n";
print "// This functions is the onKeyPress event handler for the password field\n";
print " var key;\n";
print " // Test of MSIE DOM without all that parsing of the agent string\n";
print " // NN and MSIE use different DOMs\n";
print " if (document.all) {\n";
print " key=window.event.keyCode;\n";
print " }\n";
print " else {\n";
print " key=keypressed.which;\n";
print " };\n";
print " // Check each key pressed for character code 13 (carriage return), AND\n";
print " // then SUBMIT the form for the user\n";
print " if (key==13) {\n";
print " document.forms[0].submit();\n";
print " }\n";
print "}\n";
print "</SCRIPT>\n";
print "</HEAD>\n";
print "<body bgcolor=\"#ffffff\" );\">\n";
print "<CENTER>\n";
print "<Font face=arial size=-1><BR>To view your subscriptions, please enter your User ID (User Name) and Password</FONT>\n";
# print "The number of pairs are $#pairs\n<BR>";
if ($#pairs eq 0) {
($key, $value) = split(/=/, $pairs[0]);
# $value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# $value =~ tr/\cM/\n/;
print "<h2>Error: " . $value . "</h2>";
}
print "\n";
print <<to_screen;
<Script language=javascript>
<!--
function validate(the_form){
if (the_form.password.length > 0){
the_form.submit();
}else{
alert("The password field can not be blank.");
}
}
//-->
</Script>
to_screen
print "<FORM name=\"loginform\" action=\"/SCRIPTS/loginConfirm.pl\" method=\"post\">\n";
print "<TABLE cellspacing=\"20\" cellpadding=\"0\" border=\"0\">\n";
print "<TR>\n";
print "<TD valing=\"center\" align=\"right\">\n";
print "<B>UserID: </B>\n";
print "</TD>\n";
print "<TD valing=\"center\" align=\"left\">\n";
print "<INPUT TYPE=\"text\" NAME=\"login\" size=\"20\" value=\"\">\n";
print "</TD>\n";
print "</TR>\n";
print "<TR>\n";
print "<TD valing=\"center\" align=\"right\">\n";
print "<B>Password: </B>\n";
print "</TD>\n";
print "<TD valing=\"center\" align=\"left\">\n";
print "<INPUT TYPE=\"password\" NAME=\"password\" size=\"20\" value=\"\">\n";
print "</TD>\n";
print "</TR>\n";
print "<TR>\n";
print "<TD colspan=\"2\" align=\"center\"><Input type=button value=Login </TD>\n";
print "</TR>\n";
print "</TABLE>\n";
print "</CENTER>\n";
print "</FORM>\n";
&print_footer;
print "<script language=\"JavaScript1.2\">\n";
print "document.forms[0].password.> print "</script>\n";
print "</BODY>\n";
print "</HTML>\n";
}
else {
print "Content-type: text/html\n\n";
print "<HTML>", "\n";
print "<HEAD>" , "\n";
print "<TITLE>Welcome to Connect</TITLE>", "\n";
print "<SCRIPT LANGUAGE=\"JAVASCRIPT\">", "\n";
print "{", "\n";
print " window.location.replace(\"/SCRIPTS/loginConfirm.pl\");", "\n";
print "}", "\n";
print "</SCRIPT>", "\n";
print "</HTML>", "\n";
exit(0);
}
exit(0);
###################################################################
###################################################################
__END__
# SERVER_PARAMS
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
