CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
logon script

 



keith2045
Deleted

Mar 21, 2001, 7:31 PM

Post #1 of 2 (219 views)
logon script Can't Post

I need a script that will allow users to log on to their account, i have tried to make one but had lots of problems, like it will match username but not password, wont print information. So i was wondering how i could get information from another cgi? Like i want to have a logon script where they logon and if sucessful it passes their username to account so it can search a file for their information for updating, how would i do this?

Thanks

Keith



DSelver
Novice

Mar 21, 2001, 9:25 PM

Post #2 of 2 (216 views)
Re: logon script [In reply to] Can't Post

Hey wow! that is the exact problem I am tackling at the moment. I have previously made a script that works for updating information, but it only used one piece of info. to find the user's record. It could use email address, account number, or order number.

This go around, I want the user to be able to see multiple records. (It is really a different program for a different purpose. but why re-create the entire wheel). I have the logon procedure set and tested. Now I'm just working on the reading of a file. and more importantly the adding of a database record number to each record added. How the heck am I going to add a record number? I can't go on the account number anymore because there could be multiple records with the same account number. Oh well.

Enough rambling. Here is what I did for the password verification. I used Customer Number and SiteID(the password)

I created a file called userdb and filled it with test data.

101|site1
102|site2

This is the code I used
The spliting of the variables from the login HTML page has just been completed. We pick up the code at that point.


Code
#assign variables for later comparisons 
$f_custnum = $FORM{'custnum'};
$f_siteid = $FORM{'siteid'};

#tracking environment variables
$ia = $ENV{REMOTE_ADDR};
$ih = $ENV{REMOTE_HOST};

#open the file for reading and assign it the handle 'inf'. (with some error handling tacked on at the end)

open(INF,"/projectrecnum/userdb") or dienice("Couldn't open user database for reading: $! \n");

#assign the data to the array @data
@data = <INF>;

#close the file
close(INF);

#Start loop A - for every line in the array @data
foreach $line(@data) {

#get rid of the \n at the end of each item in the array
chomp $line;

Split each $line into the following variables and use the | character as a delimeter
($custnum,$siteid) = split(/\|/,$line);

# Check to see if the custnum from the form is the same as the custnum from the file. AND check to see if the site id from the form is the same as the site id from the file.

if (($f_custnum eq $custnum) && ($f_siteid eq $siteid)) {
#Access granted here. continue the perl script and insert other web page stuff here

#ends the Access granted script
die;
#end of Access granted loop
}

#end LoopA
}
#start the password failure section

#if the last read records still match then start failure loop
if ($f_custnum ne $custnum or $f_siteid ne $siteid) {

#{insert web page failure notification here}

#end the script
die;

#close the failure loop
}

#die one more time just in case..
die;

Well now I'm working on reading in the records of the second database and handling multiple 'duplicates' if you will. To keep from having duplicates, I want to add those record numbers. (any ideas Sleuth?) Of course displaying out those record numbers with a hyperlink that will take you to the edit page is my ultimate goal.

Anyway, Thanks for letting me ramble on. (as if you had a choice....but of course you could have just skipped all of this nonsense.)

-DSelver


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives