Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
No such thing as a small change
 
PerlMonks  

Re: Re: UBB find user id code

by LeGo (Chaplain)
on Oct 09, 2001 at 21:14 UTC ( [id://117870]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: UBB find user id code
in thread UBB find user id code

I do appreciate the suggestions. I like what you have much more than what I had.

As to your last question that is just what UBB does. That is not something that I do. It is something that seems slow for my use, but I have to work with what they have given me. Again, Thanks.

My code as stands is now the following taking information from all of the above users. Thanks to those. This works and the subroutine will return either undef or the users id.

#!d:\perl\bin\perl.exe -w use strict; use CGI; use CGI::Cookie; print "Content-type:text/html\n\n"; my $user = get_userid(); print "UNDEF" if($user eq undef); print "<p>whoa whoa whao $user" if($user ne undef); sub get_userid { my $member_dir = "../../Members/"; my $member_file ="memberslist.cgi"; return undef unless my %cookies = CGI::Cookie->fetch; return undef unless $cookies{'UserName'} and $cookies{'Password'}; my $id = $cookies{'UserName'}->value; my $password = $cookies{'Password'}->value; my $exact_file; my $file = "$member_dir/$member_file"; open (FH, "< $file") or die "Could not open $file: $!"; while( my($login, $junkfile) = split /\|!!\|/, <FH>) { if ($login eq $id) { chomp $junkfile; $exact_file = $junkfile; last; } } close FH; return undef unless $exact_file; $file ="$member_dir/$exact_file.cgi"; open (FH, "< $file") or die "Could not open $file"; chomp (my @user_list= (<FH>, <FH>)); close FH; return undef unless $user_list[0] eq $id and $user_list[1] eq $password; return $id; }
LeGo

Replies are listed 'Best First'.
Re: Re: Re: UBB find user id code
by tommyw (Hermit) on Oct 09, 2001 at 21:57 UTC

    D'oh! The point of undef is that it evaluates to false in logic statements (see the compound statement section of perlsyn). So you don't need to explicitely test against it:

    my $user = get_userid(); print "UNDEF" unless $user; print "<p>whoa whoa whao $user" if $user;
    (oh, you don't need to bracket the conditions, when they're modifiers, and unless is the equivalent of "if not")

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://117870]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.