Gossamer Forum
Home : Products : DBMan : Customization :

Discussion: $db_key

Quote Reply
Discussion: $db_key
Thx to LoisC, I figured out how to get my database to force "new" users to add a record, where subsequent visits would "not" get the Add Record prompt, :-)

However, the only way I got it to work was by changing the $db_key from the original AlumniID (counter) to the UserID.

The problem (or is it?) is that a few of my records use the same UserID, :-0. I've cautioned my alumni to "not" update any thing other then their entry, but I understand how they'd want to update their sibling off-line folks to the database, "understanding", they are ultimately responsible for updates of those siblings.

The .cfg states, "The column name for the database key. Can be any column, but it must be unique! You can't have two records with the same key value! So ... if I change to User-Id, I have multiple records with the same key value -- if I leave it as the AlumniID (counter), I can't get it force the Add AND not stop the subsequent visits from getting the Add form, :-0.

Suggestion, Comments?

JR
Quote Reply
Re: Discussion: $db_key In reply to
I had a similar problem; solved it by adding a field to the database (something like "entry id"), which was hidden to all the users (i.e. in all the forms used for display).

Hope this helps,

kellner
Quote Reply
Re: Discussion: $db_key In reply to
Kellner,

Thx much 4 yr reply, it makes perfect sense, 'cept I don't think it will work for my purposes ... course, I've been wrong in this forum many o'time, ACK!

Top of my sub html_home looks like this ...

Code:
%rec = &get_record($db_userid);
if (!%rec) {
print "Location: $db_script_url?db=default&uid=$db_uid&add_form=1\n\n";
return;
}

...default.cfg looks like this ...

Code:
%db_def = (
'AlumniID' => [ 0, 'alpha', 3, 3, 0, '', ''],
'Date' => [ 1, 'date', 12, 15, 1, &get_date(), ''],
'Year Grad' => [ 2, 'alpha', 0, 15, 1, '', ''],
'Title' => [ 3, 'alpha', 0, 4, 0, '', ''],
'Last Name in School' => [ 4, 'alpha', 20, 50, 0, '', ''],
'Married Name' => [ 5, 'alpha', 20, 50, 0, '', ''],
'First Name (Nickname) & Spouses Name'=> [ 6, 'alpha', 20, 100, 0, '', ''],
'Street Address' => [ 7, 'alpha', 20, 100, 0, '', ''],
'City/State/Country' => [ 8, 'alpha', 20, 100, 0, '', ''],
'ZIP/APO/FPO' => [ 9, 'alpha', 20, 50, 0, '', ''],
'Phone/FAX' => [10, 'alpha', 20, 100, 0, '', ''],
'Email Address' => [11, 'alpha', 20, 100, 1, '', '.+@.+..+'],
'URL(s)' => [12, 'alpha', 20, 100, 0, 'http://', '^http://'],
'Will you be attending AtlantaY2K'=> [13, 'alpha', 0, 9, 1, '', ''],
'Receive Email' => [14, 'alpha', 0, 5, 1, 'Yes', 'Yes|No'],
'Comments' => [15, 'alpha', '40x3', 1000, 0, '', ''],
'UserID' => [16, 'alpha', 10, 12, 0, '', '']
);

# The column name for the database key. Can be any column, but it must be unique!
# You can't have two records with the same key value!
$db_key = 'UserID';

With the above code it forces the new user to add a record, but subsequent visits they're not forced to add a record --- that's the goal ...

Unfortunately, I "think" I need to leave "AlumniID" as my $db_key, as it's the only truly unique column field. If I add another hidden field, as I'm understanding from yr reply, that I would make that field the $db_key, which, unfortunately, I "think" will put other things in the database all out of whack. Ex: by changing from AlumniID to UserID, my File-Upload Mod and Export to Excel Mod's will be affected they use the $db_key (AlumniID [counter])field.

So ... I'm either understanding what to do with yr reply wrong, or I think I need a code hack to my sub html_home

Any takers on the above?

JR
Quote Reply
Re: Discussion: $db_key In reply to
Why do you have two userid fields? The easy answer, of course, is to keep the AlumniID field as the $db_key field. I don't know how changing the db_key variable to AlumniID field would disrupt the Excel Export Mod. Couldn't you re-define the fields in the Export Mod?

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Discussion: $db_key In reply to
Eliot,

The original distribution has ID and User-Id. I only changed to AlumniID and User-Id because Excel reads "ID" as a SYLK error.

Maybe I misspoke on the potential snafu with the Excel mod, 'cept that I don't know how having "User-Id" as the $db_key would affect the output of multiple records with the same userid.

That said, the AlumniID also defaults as 1.jpg, 2.jpg, 3.jpg etc., for the File-Upload Mod. Changing to User-Id (where some of my alumni have entered multiple records under the same userid) will result in my db being all out of whack ... right?

YES, I want to leave AlumniID as my $db_key! But it doesn't seem to work with the aforementioned sub html_home code, 'less I change the $db_key to User-Id, :-0, e.g., this discussion on the value of $db_key.

JR
Quote Reply
Re: Discussion: $db_key In reply to
I'm not sure I understand why your users would have more than one record each. But there must be a reason. Smile

I don't think you can force new users to add a record unless the $db_key is the userid field.

Wait a minute. Sure you can. Instead of

Code:
%rec = &get_record($db_userid);
if (!%rec) {
print "Location: $db_script_url?db=default&uid=$db_uid&add_form=1\n\n";
return;
}

Use

Code:
$in{'Userid'}=$db_userid;
my ($status, @hits) = &query("view");
if ($status ne "ok") {
print "Location: $db_script_url?db=default&uid=$db_uid&add_form=1\n\n";
return;
}

This will search for any record in the database that has the userid, and, if nothing is found, they will be forced to go to the add form. It still allows them to add more records, though.

Is this what you wanted?


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





Quote Reply
Re: Discussion: $db_key In reply to
JPD,

The problem with the above, even with yr latest modification, is that every time the user tries to log in, they get the Add Record Form, i.e., doesn't recognize the userid.

To the why users have more than 1 record ... No matter how much I caution them AGAINST entering more than 1 record, they still insist on updating their off-line sibling, friends, etc., i.e., the same user-id for John Doe, Jane Doe, etc., :-0.

Note: I tried the $db_key with both AlumniID and UserID ... same result. Which one should I use ... understanding that AlumniID (the counter) is attached to the File Upload and Excel Mod's.
Quote Reply
Re: Discussion: $db_key In reply to
Well, then, it's time for debugging.

Are you sure you have a field for UserID on your form and that it is set when a record is added? Take a look at your .db file to make sure that all of the records have the UserID field.

If so, try adding a temporary line to sub html_add_form --

print "$db_userid";

This will let you see if the $db_userid variable is being set correctly.

If it's not finding records, there's three possible problems -- the UserID is not being added to the records, $db_userid is not being computed correctly or there's a problem with your search. The first two are easier to deal with, so we'll try them first.

The way to prevent people from adding more than one record is to set the $db_key to the UserID field. If they want to add their brothers or second cousins once removed, they can sign up for another UserID. But then, I have very little patience with people these days. Smile And I understand that you may have other reasons that you need to have a counter as the $db_key.


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





Quote Reply
Re: Discussion: $db_key In reply to
Problem solved! I think.

1. I painstakingly changed all the AlumniID values attached to the file upload mod to UserID.
2. Changed
Code:
$in{'Userid'}=$db_userid;
to
Code:
$in{'UserID'}=$db_userid;
3. Made the AlumniID null

Now everything "seems" to be in order, short of the anticipated complaints I'm gonna get from those alumni that just want to browse, that can no longer view w/o having to enter their record ... they'll get over it, <g>.

One last question tho'. I've seen the threads talking pro's and con's against removing the Add/Footer from the Add form. What's the best suggestion?



[This message has been edited by joebagodonuts (edited March 19, 2000).]
Quote Reply
Re: Discussion: $db_key In reply to
Well, at least I know that my problem with typos is still there. (There's comfort in knowing that some things always stay the same. Smile )

Glad you got it fixed.

Not having been here to see the discussion about the footer, I'm not sure what has been said before. I'll give you my take on it.

I don't like having an "Add" link on the add form. I think it's confusing, especially for new folks. When I started with DBMan back in the stone age, after I'd filled out the form, I wasn't sure whether I should click the Add link or the button. So there's one reason it shouldn't be on the add form.

If you're going to force new users to add a record before they do anything else, it would be best to have no links in the footer where they are able to go onto any other page. Don't give people options you don't want them to use.

If you force new folks to add a record and folks can only have one record, there is no need to have the Add link in the footer at all. Again, there's no need to tempt them to do something you won't let them do.

Does this make sense?


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





Quote Reply
Re: Discussion: $db_key In reply to
JPD,

Fortunately, this forum, other threads, trial & error and EditPlus has helped me immensely. That coupled with me looking for things like the difference between parenthesis, braces, brackets and case have also done wonders, in my mind, toward solving the small problems.

Conversely, I'm the "creatively acquired" unpaid volunteer type, so I sometimes may ask the bonehead questions ... solicit yalls understanding, <g>

To the footer issue, the discussion was whether to completely "remove" the add in the footer or simply change permissions to per admin. Eliot commented, to the effect, that by removing the Add, that takes away from the admin being able to add, if necessary. That sounds on target with what I'm wanting to do, so I've changed the permission to per admin.

Lastly, experience with my alumni users tells me I need to ween them from one modification to another, i.e., NOT take away ALL the options away at once, otherwise I either lose them or get inundated with How To email.

My target audience is from Izmir Amer High School, Izmir, Turkey, where the average graduating class is less than 20 people. I've been successful encompassing 40 years of alumni, friends of, and siblings to the count of 232, but this bunch is, at times, slow in coming in this Generation X age.

Thx again for yr help.

------------------
Joebagodonuts, JR or Anita
http://home.flash.net/~murgnam/
Quote Reply
Re: Discussion: $db_key In reply to
I'm not quite following this.

Immediatly after people sign up I want to force them to add a record to my members.db (which is a second db aside from my default.db)

They will only be able to add one record, at the time of sign up. This information will be personal, so nobody can see other members information. I do want them to be able to modify it though at any time.

Any help is appreciated.

Adam
Quote Reply
Re: Discussion: $db_key In reply to
Adam:

To force a new user to add a record once they login you would only need to add:

Top of my sub html_home (members html.pl file) code:

if ($per_add) {
%rec = &get_record($db_userid);
if (!%rec) {
print "Location: $db_script_url?db=user&uid=$db_uid&add_form=1\n\n";
return;
}
}

JR's situation may be confusing you due to some changes he's been making with field names, etc.

Hope this helps Smile







%rec = &get_record($db_userid);
if (!%rec) {
print "Location: $db_script_url?db=default&uid=$db_uid&add_form=1\n\n";
return;
}

Quote Reply
Re: Discussion: $db_key In reply to
Is there a known reason why it prompts me to add a record each time I log in and not just the first time?

Thanks.
Adam

Quote Reply
Re: Discussion: $db_key In reply to
Is your $db_key field defined as your userid field?

JPD
Quote Reply
Re: Discussion: $db_key In reply to
It is now :-) and now it seems to work! :)

Thanks!
Adam