crimson30,
"..I used the ActivePerl FAQ this time to config since I have PWS 5.0 ..."
Can you post that method here? is it very different from the one i posted before?
Pl. let me know.
"..I ran env.pl and got the all the env var keys..."
Excellent!! Glad to know that PERL scripts are working fine now.
"..On to the text input login/password script? .."
Here is the HTML form and PERL script called by the HTML form that allow a user to select a username/password, check that username is unique and if it is unique store it in a text file.
The password is stored in an encrypted format.
NOTE: i have commented the code so that you will find it easier to understand and maintaint the same.
======pass.pl
#!/usr/local/bin/perl
use CGI;
$query=new CGI;
print "Content-type: text/html\n\n";
if ($query->param){ ## User clicked on the submit button.
$pwd_file="c:\\temp\\passwd.txt";
## Read the username and password from the HTML form
$username=$query->param('u_name');
$newuser=$query->param('pass');
## Some basic validations!!
if ($username=~ /^$/ || $username=~ /^\s+$/){ ## Reject Empty username
print "Username cant be blank!!\n";
}else{
if ($newuser=~ /^$/ || $newuser=~ /^\s+$/){ ## Reject Empty password
print "Password cant be blank!!
\n";
}else{
if (-e $pwd_file){ ## Open the password file, if it already exist!!
## Check if the username has already been taken
open(PWD,$pwd_file) || die $!;
@pwds=;
close(PWD);
}
## Store the existing username/passwords in a hash/associative
## Array. the username is the key to the array.
foreach(@pwds){
($uname,$pwd)=split(/\t/,$_);
chomp($pwd); ## Remove the enter char.
$PASSWD{$uname}=$pwd;
}
if ($PASSWD{$username}){ ## Username already taken!!
print "Please use some other username\n";
}else{ ## ALL is OK!!
## Use the Process id & time to generate the salt.
srand($$|time); # random seed
@saltchars=(a..z,A..Z,0..9,'.','/'); # valid salt chars
$salt=$saltchars[int(rand($#saltchars+1))]; # first random salt char
$salt.=$saltchars[int(rand($#saltchars+1))]; # second random salt char
## Encrypt the password
$newuser = crypt ($newuser, $salt);
$PASSWD{$username}=$newuser;
## Write this new username/password to the file
open(PASS,">$pwd_file") || die $!;
foreach(keys %PASSWD){
print PASS $_."\t".$PASSWD{$_},"\n";
}
close(PASS);
print "Welcome, Your account is now ready!!
\n";
exit;
}
}
}
}
print qq{
>
Enter username
Enter password
};