Greetings,
I have a CGI script (in rudimentary Perl) that takes login name and password data, compares it to a database, and if it matches, prints one page, if no match, redirects back to the login page with an error message. This all works fine.
My problem is that if one enters the location of the CGI script in the address bar, he is admitted through without a login name and password. I'm missing the component that tests to see if there is any incoming data to begin with, then redirects back to the login page if not. Please help.
Obviously, there's more, but I believe the necessary piece would fit in here somewhere. Actual page is at login page is at
Thanks so much!
Meghan
I have a CGI script (in rudimentary Perl) that takes login name and password data, compares it to a database, and if it matches, prints one page, if no match, redirects back to the login page with an error message. This all works fine.
My problem is that if one enters the location of the CGI script in the address bar, he is admitted through without a login name and password. I'm missing the component that tests to see if there is any incoming data to begin with, then redirects back to the login page if not. Please help.
Code:
#!/usr/bin/perl
#Line above gives path to Perl interpreter
require "cgi-lib.pl";
#Read incoming data into an array and set content type
&ReadParse;
print &PrintHeader;
#Set default test results to no match
$match="no";
#Open user database in read-only mode
open(FILE,"cmaa.txt") || die "Can't find database\n";
#Store contents of database in an array
@indata = <FILE>;
#Close database
close(FILE);
#Extract each record from the @indata array
foreach $i (@indata)
{
#Remove hard return
chomp($i);
#Assign names to variables
($fname,$lname,$co,$add,$city,$st,$zip,$tele,$email,$pwd1,$pwd2) = split(/\|/,$i);
#Compare login data to array
if ($fname=~/$in{'fname'}/i && $lname=~/$in{'lname'}/i && $pwd1=~/$in{'pwd'}/i)
{
$match="yes";
# Print personalized CMAA page
Obviously, there's more, but I believe the necessary piece would fit in here somewhere. Actual page is at login page is at
Thanks so much!
Meghan