Click to See Complete Forum and Search --> : passwords & auto form fill
lamborn
01-19-2004, 06:04 PM
Hello,
I am _wondering if it is possible using CGI to have a master LogIn page where a user would enter their user name and password to get into another protected page with an input form on it.
And based upon their user name entered on the login page, some fields of the form on the second page would be auto filled in, so that each time this user comes back they do not need to fill in repetitive info.
Make sense
Any help, or nudges in the right direction would be great.
bl
garfvader
01-19-2004, 09:46 PM
Hmm my first inclination would be to build that into your login cgi.
So basically you have a password file with usernames and encrypted passwords. You have a form page with login and password. A person puts in their username and password and hits the login button which calls the cgi. The cgi encrypts the password, compares it to the password file and if it matches for that username, then the cgi outputs the html for the second input form page.
The first time a user fills out the input form page, it could create a file for that username containing the data they already filled in. Then the next time the user logs in, the login form can check to see before outputting the html for the input form if a file belonging to that username exists. If so, it can insert the values in the proper places in the html that it outputs.
Hehe did that make sense? That's at least the first thing that comes to mind.
lamborn
01-20-2004, 11:11 AM
Make perfect sense. I'll be diving into my big book of Perl for Dummies to see what I can come up with.
Cheers
Scriptage
01-20-2004, 10:14 PM
hmmm:
why not do this?
#!/usr/bin/perl -w
use CGI qw(:all);
use strict;
my $username = param("username");
my $password = param("password");
my $some_item = param("some_item");
dbmopen(my %passwords, "passfile", 0700) || die "Cannot open password file: $!";
my $enc_password = $passwords{$username};
dbmclose(%passwords);
if(crypt($password, substr($enc_password, 0, 2)) eq $enc_password){
print<<HTML_PAGE_HERE
<html>
<head>
<title>Welcome: $username</title>
</head>
<form name="auto_form">
<input type="text" name="some_item" value="$some_item">
</form>
</html>
HTML_PAGE_HERE
}else{
print<<ERROR_PAGE_HERE
<html>
<head>
<title>Error: Failed Login</title>
</head>
You failed to login
</html>
ERROR_PAGE_HERE
}
exit(0);