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:
What would casue OPEN command to only ready first record?

 



DippinPete
Deleted

Dec 2, 2000, 12:42 PM

Post #1 of 3 (987 views)
What would casue OPEN command to only ready first record? Can't Post

Here's the code:

#!/usr/bin/perl

sub login_lookup

{

local ($page_title) = @_;

local ($hidden_fields) = &make_hidden_fields;

#print qq!

$lookup_email_now = $form_data{'id_login_email'};
$lookup_password_now = $form_data{'id_password_login'};

open(FILE,"$ENV{'DOCUMENT_ROOT'}/cgi-local/form1.bout")| |die "Can't Read file";

@records=<FILE>;
foreach $rec(@records){
($login_b_first_name,$login_b_middle_in,$login_b_last_name,$login_b_add1,$login_b_add2,$login_b_city,$login_b_state,$login_b_zip,$login_b_country,$login_b_phone,$login_b_fax,$submi t_by,$loginpassword,$login_how_found,$mailing_list,$login_date,$login_time)=split(/\|/,$rec);

if ($lookup_email_now eq $submit_by){
print "We have this user name on record.";
exit;
}
else
{
&login_account_not_found;
exit;
}
}
}
###################################################
# Login Account Not Found #
###################################################

sub login_account_not_found

{
print "This login account has not been found, sorry";
exit;
}

1;

NOW -- What would cause this code to only read the first record and not the rest?

This code is meant to check a field and see if it is in the file (form1.bout)... only it will only work with the first record...

Thanks,

Pete


and_drew
Deleted

Dec 2, 2000, 9:46 PM

Post #2 of 3 (987 views)
Re: What would casue OPEN command to only ready first record? [In reply to] Can't Post

What you have to do is take the exit; out of the foreach loop.

Put the exit after the }'s you will have to experiment where it should go but i think just after the closing of the sub } will make your program work fine.

Drew www.cgishack.com

------------------
Vist www.cgishack.com today and see hot scripts!


DippinPete
Deleted

Dec 3, 2000, 7:35 AM

Post #3 of 3 (987 views)
Re: What would casue OPEN command to only ready first record? [In reply to] Can't Post

Thank you, although your post was short, it told me what I needed!! Thank you very very very much. Below is the correct and working code, perhaps it will help someone down the road...

#!/usr/bin/perl

sub login_lookup

{

# local ($page_title) = @_;
#
#local ($hidden_fields) = &make_hidden_fields;
#
######print qq!

$lookup_email_now = $form_data{'id_login_email'};
$lookup_password_now = $form_data{'id_password_login'};

open(FILE,"$ENV{'DOCUMENT_ROOT'}/cgi-local/form1.bout")&#0124; &#0124;die "Can't Read file";
##########open(FILE,"form1.bout")&#0124; &#0124;die "Can't Read file !";

@records=<FILE>;
foreach $rec(@records){
($login_b_first_name,$login_b_middle_in,$login_b_last_name,$login_b_add1,$login_b_add2,$login_b_city,$login_b_state,$login_b_zip,$login_b_country,$login_b_phone,$login_b_fax,$submi t_by,$loginpassword,$login_how_found,$mailing_list,$login_date,$login_time)=split(/\|/,$rec);

if ($lookup_email_now eq $submit_by && $lookup_password_now eq $loginpassword){
print "We DO INDEED have this user name AND password on record.";
exit;
}
}
&login_account_not_found;
}
###################################################
# Login Account Not Found #
###################################################

sub login_account_not_found

{
print "This login account cannot be verified, sorry.";
exit;
}

1;

 
 


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

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