Gossamer Forum
Home : Products : DBMan : Customization :

Syntax for ....

Quote Reply
Syntax for ....
My programing skills are still not up to par with you guys yet! So could you help me with some language? What I would like to write is in this order.

1) Open members.db file look for userid in the member.db file
2) if found continue on
3) else goto html_member_add_form

I have to code posted at http://sherwingaddis.hypermart.net/cgi-bin/dbman/perl/html.txt

Right after Home Page is where I will be entering the code. Thanks

------------------
Sherwin Sales@jse.net
Quote Reply
Re: Syntax for .... In reply to
I don't gaurantee this will work, but you can try it: (I will break this up into steps and then include the complete codes at the end of this response.)

1) Open Database

Code:
open (MEMDB, ">>$db_mem_file_name") or &cgierr("error in add_record. unable to open database: $db_file_name.\nReason: $!");
if ($db_use_flock) {
flock(MEMDB, 2) or &cgierr("unable to get exclusive lock on $db_mem_file_name.\nReason: $!");
}
close MEMDB;

Note: $db_mem_file_name should be defined in the members.cfg file. You can change this to the physical path and file of your members.db file, like in the following codes:

Code:
/machine/app/myaccount/cgi-bin/dbman/members.db

2) Compare database login id with id in the members.db.

Code:
@members = <MEMBER>;
foreach $mem (@members) {
@data = split "\|/",$mem;
$memid = $data[1];
last;
}
unless ($db_userid eq $memid) {
&html_member_add_form;
}
else {
$in{'modify'} = $db_userid;
return;
}

Complete Codes:

Code:
open (MEMDB, ">>$db_mem_file_name") or &cgierr("error in add_record. unable to open database: $db_file_name.\nReason: $!");
if ($db_use_flock) {
flock(MEMDB, 2) or &cgierr("unable to get exclusive lock on $db_mem_file_name.\nReason: $!");
}
@members = <MEMBER>;
close MEMDB;
%rec=&get_record($db_userid);
foreach $mem (@members) {
@data = split "\|/",$mem;
$memid = $data[1];
last;
}
unless ($db_userid eq $memid) {
&html_member_add_form;
}
else {
$in{'modify'} = $db_userid;
return;
}

BTW: Don't know if you know this or not, but you do NOT have a closing right bracket after your sub html_home. Also, I don't if you are using separate html.pl files, but if you are NOT, then you need to distinguish which databases people are accessing in the hidden fields of your forms.

Again, I don't know if this will work and it is not clean codes that Carol can provide, but it may give you are a running start. Please make sure that you have a clean backup of your html.pl file before attempting this Mod.

Hope this helps.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------




[This message has been edited by Eliot (edited November 02, 1999).]