Gossamer Forum
Home : Products : DBMan : Installation :

Anyone else creating a MEMBERSHIP DIRECTORY?

Quote Reply
Anyone else creating a MEMBERSHIP DIRECTORY?
Hi!

I've just joined this forum after trying to figure out DBMan on my own -- NOT! I have a bit of programming experience, and I know HTML, but I'm totally new to PERL and CGI.

I run a website for a non-profit support group and am creating a membership directory (database of member profiles) with the following non-admin features:

1. In order to become a member, you must sign up (create userID and password), login, and create your own profile (record). I'd prefer this be done with one form, but that seems like it would require a major rewrite.

2. Anyone can join without admin approval, but you must become a member before you can search for and view other members' profiles.

3. You can only modify or delete your own record.

4. Only one record per member is allowed, so the add_record routine should only be accessed during the initial registration, and the delete routines should also delete the member's UserID and password from the file default.pass (which I have renamed members.pass).

Is anyone else out there working on this kind of application?

Are there any documented mods I should know about?

Here is my current dilemma...
I'm trying to redo the html_footer subroutine of html.pl (the 'user friendly' version) so that non-admin users get these links:

'SEARCH database', 'VIEW your record', 'MODIFY your record', and 'DELETE your record'

instead of the usual View, Delete, and Modify, which force a search even if only the user's record is desired. How do I make my VIEW, MODIFY, and DELETE links send the user straight to their own record or record form?

Thanks in advance, and special thanks to JPD for a job well done!

Scott Noelle
mailto:noelles@teleport.com
Quote Reply
Re: Anyone else creating a MEMBERSHIP DIRECTORY? In reply to
You're welcome!! Thank *you*!

Code:
print qq!<P align=center><$font>!;
print qq!| <A HREF="$db_script_link_url">Home</A> !;
print qq!| <A HREF="$db_script_link_url&view_search=1">SEARCH database</A> !
if ($per_view);
print qq!| <A HREF="$db_script_link_url&$db_key=$db_userid&view_records=1">VIEW your record</A> !
if ($per_view);
print qq!| <A HREF="$db_script_link_url&$db_key=$db_userid&modify_form=1">MODIFY your record</A> !
if ($per_mod);
print qq!| <A HREF="$db_script_link_url&$db_key=$db_userid&delete_form=1">DELETE your record</A> !
if ($per_del);
print qq!| <A HREF="$db_script_link_url&view_records=1&$db_key=*">List All</A> !
if ($per_view);
if ($per_admin) {
print qq!| <A HREF="$db_script_link_url&admin_display=1">Admin</A> !;
print qq!| <A HREF="$db_script_link_url&add_form=1">Add</A> !;
print qq!| <A HREF="$db_script_link_url&delete_search=1">Delete</A> !;
print qq!| <A HREF="$db_script_link_url&modify_search=1">Modify</A> !;
}
print qq!| <A HREF="$db_script_link_url&logoff=1">Log Off</A> |!;
print qq!</font></p>!;

That should do it. Those with admin permissions can still add, modify and delete records, but regular users will get their own records.

If someone knew a lot about DBMan, they might be able to get to the add form and try to add a new record, but, since the userid is the key, the record wouldn't be added.

Anything else? Smile

-----------------
JPD



[This message has been edited by JPDeni (edited August 02, 1999).]
Quote Reply
Re: Anyone else creating a MEMBERSHIP DIRECTORY? In reply to
Thanks for the fast reply!

I'll try your suggestions, but could you check your last post and see if you accidently left out some of the code?

It looks like something is missing after

> To require the user to add their profile when they first sign up, add the following to the beginning of html_home:

and

> In db.cgi, look for sub delete_records. Find

...Or am I going bonkers!? Smile

Scott Noelle
mailto:noelles@teleport.com
Quote Reply
Re: Anyone else creating a MEMBERSHIP DIRECTORY? In reply to
Sure did. Smile Things got kinda messed up when I edited my post. I thought I'd caught it all.

To require the user to add their profile when they first sign up, add the following to the beginning of html_home:

Code:
%rec = &get_record($db_userid);
if (!%rec) {
&html_add_form;
return;
}

Oh, man! What a drag! The longest, most complicated code got lost. Hmmmm. Maybe I still have it on my computer. Just a sec.

Yay!

Okay. Open up db.cgi and find sub delete records. Look for:

Code:
$delete_list{$data[$db_key_pos]} ? # if this id is one we want to delete
($delete_list{$data[$db_key_pos]} = 0) : # then mark it deleted and don't print it to the new database.
($output .= $line . "\n"); # otherwise print it.

and replace it with the following:

Code:
if ($delete_list{$data[$db_key_pos]}) {
$delete_list{$data[$db_key_pos]} = 0;
open (PASS, "<$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) { flock(PASS, 1) } @passlines = <PASS>;
close PASS;
open (PASS, ">$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) {
flock(PASS, 2) or &cgierr("unable to get exclusive lock on $auth_pw_file.\nReason: $!");
}
foreach $passline (@passlines) {
($passlineline =~ /^$in{'username'}:/) ?
($passfound = 1) :
print PASS $line;
}
close PASS;
}
else {
$output .= $line . "\n";
}

Did I miss anything else? Smile

------------------
JPD