[ back to toc ]

cgi scripting

Date: 2002/02/25 13:49

I created a few cgi scripts that worked before but this one doesn't. I
wanted it to be a login and password verifying script for a few people
using the "if" (very simple) but it didn't work:
Html: "<form action="post.cgi" method="post">
... <input type="text" name="user"> ...
<input type="pass" name="pass">...
Cgi: #!/usr/bin/perl

print "Content-type:text/html\n\n";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

@pairs = split(/&/, $buffer);

foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);

$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;

$FORM{$name} = $value;


print "<html><head><title>Form Output</title></head><body
if ($Form{'user'} eq "doron" and $Form{'pass'} eq "doran") {
print "<h2>It's working!!!</h2>\n";
print "<h2>Results from FORM post</h2>\n";

foreach $key (keys(%FORM)) {
print "$key = $FORM{$key}<br>";

print "</body></html>";

my server is netfims.com
why doesn't it work (the if block), I get only the form results and not
the "it's working part" when I put the right password and user in.
Try to print out the $Form{'user' } and $Form{'pass'} variables. Also try
to use && instead of and.

At first glance the program seems to be ok.


[ back to toc ]