#!/usr/bin/perl # Program to write data to a text file use CGI qw(:standard); use CGI::Carp(fatalsToBrowser); $firstname = param("firstname"); $lastname = param("lastname"); $email= param("email"); $country = param("country"); $username= param("username"); $password= param("password"); $rpassword = param("rpassword"); print "Content-type: text/html\n\n"; print "\n"; print "
\n##
#!/usr/bin/perl
use CGI qw(:standard);
$testUsername = param("username");
$testPassword = param("password");
open (FILE, "password.txt") || die "File cannot be opened";
while($line = )
{
chomp $line; # removes carriage return
($username, $password) = split(", ", $line);
if ($testUsername eq $username) {
$userVerified = 1;
if ($testPassword eq $password) {
$passwordVerified = 1;
last; # go to the last line
}}}
close (FILE);
print "Content-type: text/html\n\n";
print "\n \n”;
if ($userVerified &&$passwordVerified) {
accessGranted(); }
elsif ($userVerified && !$passwordVerified) {
wrongPassword(); }
else {accessDenied(); }
sub accessGranted {
print "Permission has been granted, $username."; }
sub wrongPassword {
print "You entered invalid password."; }
sub accessDenied {
print "You have been denied access to the server."; }