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:
user validation

 



perlmonkey
Deleted

Feb 6, 2000, 6:37 PM

Post #1 of 4 (820 views)
user validation Can't Post

Hello,

I'm trying to create my own affiliate program. I've created small scripts which will let me sign up affiliates, issue usernames and passwords to them, log visits from affiliate links and also display the full list of accesses by all affiliate links.

Problem is, the script that redirects by way of the referral link simply uses the $ARGV to get user name (id), example:

http://go.to.tld/exec/ref.cgi?mica1
where mica1 is the user [aka - $ARGV]

it then redirects to my homepage. This works whether the link contained a valid user or not. I need to check one of the log files created by the membership agreement (refid.log), determine if the name in the requested link actually exists. If it does, then I need to append my affiliate referral log file as usual, but if it doesn't I still need to redirect to the homepage.

Any help is appreciated. Once this mystery is unraveled there are other concerns


brian.hayes
User

Feb 6, 2000, 6:53 PM

Post #2 of 4 (820 views)
Re: user validation [In reply to] Can't Post

perlmonkey,

To read the file and check for something in it.

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


my $db = '/path/to/file'
my $checking = $ARGV; # SOmewhere in your code.

open DB, $db or die("Error Reading file $!");
while(<DB> ){
shift;
if ($checking = ~/$_/i){
do something we have a match.
} elsif ($checking !=/$_/i){
do something no match!
} #Closing if statment.


} #Closing while statment.

close DB;

</pre><HR></BLOCKQUOTE>

I belive this is what your wanting, let us know.

Brian Hayes

[This message has been edited by brian.hayes (edited 02-06-2000).]

[This message has been edited by brian.hayes (edited 02-06-2000).]


perlmonkey
Deleted

Feb 6, 2000, 7:14 PM

Post #3 of 4 (820 views)
Re: user validation [In reply to] Can't Post

Thanks for the suggestion. Maybe it's just me. But, I couldn't get it to work that way either.

Basically, the script that it is in opens a database file and writes to it. It's my understanding that this entire "open" dialog would then go inside of the "if" statement as listed.? I tried but it still allows invalid user ids to be written to the logfile.

I saw in another of your articles the distinction between chop and chomp, which is what I had initially tried (chop that is) and my script didn't put either into the logfile until the username logfile included passwords. The chop was cutting off the last letter. I gotta buy a book or something....

Thanks again.


brian.hayes
User

Feb 6, 2000, 8:05 PM

Post #4 of 4 (820 views)
Re: user validation [In reply to] Can't Post

Try this.

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>



my $db = '/path/to/file';

open DB, $db or die("Error Reading file $!");

while(<DB> ){

if (m/$ARGV/i){
do something we have a match.
} elsif (!m/$ARGV/i){
do something no match!
} #Closing if statment.
} #Closing while statment.

close DB;
</pre><HR></BLOCKQUOTE>

[This message has been edited by brian.hayes (edited 02-06-2000).]

 
 


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

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