
abockover
Deleted
Aug 2, 2000, 8:24 AM
Post #1 of 4
(560 views)
|
|
Password Protecting a Sub
|
Can't Post
|
|
I have written a program that will view a flatfile database. I would like to password protect it, but what I am trying will not work. Below is the code I have. <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> #!/usr/bin/perl &parse_form; $adminpass='hey'; print "Content-type: text/html\n\n"; print "<form action='view.cgi' method='post'>\n"; print "Password: <input type='password' name='password'>\n"; print "<br>\n"; print "<input type='submit' value='Login'>\n"; print "</form>"; if ($input{'password'} eq '$adminpass') { &doView; exit('0'); } else { print "Invalid Password - Click the back button on your browser to try again."; exit('0'); } sub doView { print "print the protected html"; } sub parse_form { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); if (length($buffer) < 5) { $buffer = $ENV{QUERY_STRING}; } @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; $input{$name} = $value; } } </pre><HR></BLOCKQUOTE> Please tell me what is wrong! Thanks, Aaron
|