Gossamer Forum
Home : Products : DBMan : Customization :

UserID Field Problems

Quote Reply
UserID Field Problems
The following code is supposed to take information provided by a form and add it to the database. Not only that, but theres a small section that's supposed to take the data from a certain field (Callsign) and add "-Y" if the data from another field says yes or no.

Code:

##########################################################
## Joining ##
##########################################################

sub join_create {
# --------------------------------------------------------
# Adds the new member's record into the validation wating
# pool, E-mails an "auto-respone" to the member, and then,
# E-mails the staff officer a message telling him to come
# validate the new member. Also does some variable
# checking and editing.

my ($output, $status, $counter);
# Set the userid to the logged in user.
($auth_user_field >= 0) and ($in{$db_cols[$auth_user_field]} = $db_userid);
(!$per_admin) and ($in{$db_validated_field} = "No");

# First we validate the record to make sure the addition is ok.
$status = &validate_record;

# We keep checking for the next available key, or until we've tried 50 times
# after which we give up.
while ($status eq "duplicate key error" and $db_key_track) {
return "duplicate key error" if ($counter++ > 50);
$in{$db_key}++;
$status = &validate_record;
}

if ($status eq "ok") {

# Creates a randomly created Callsign, then adds "-Y" to
# the end if SATYTH = "Yes", otherwise, it leaves it
# alone.

@chars = (A .. Z, 0 .. 9);
$random_number = int(rand(9) + 27);
$random_char = int(rand(36));
$random_char2 = int(rand(36));
$Callsign = 'WBK' . $chars[$random_number] . $chars[$random_char] . $chars[$random_char2];
if ( $rec{'SATYTH'} eq 'Yes' ) {
$Callsign = $Callsign . "-Y"
}
else {
$rec{'Callsign'} = $rec{'Callsign'}
}

open (DB, ">>$db_file_name") or &cgierr("error in add_record. unable to open database: $db_file_name.\nReason: $!");
if ($db_use_flock) {
flock(DB, 2) or &cgierr("unable to get exclusive lock on $db_file_name.\nReason: $!");
}
print DB &join_encode(%in);
close DB; # automatically removes file lock
if ($db_key_track) {
open (ID, ">$db_id_file_name") or &cgierr("error in get_defaults. unable to open id file: $db_id_file_name.\nReason: $!");
if ($db_use_flock) {
flock(ID, 2) or &cgierr("unable to get exclusive lock on $db_id_file_name.\nReason: $!");
}
print ID $in{$db_key}; # update counter.
close ID; # automatically removes file lock
}
&auth_logging("added record: $in{$db_key}") if ($auth_logging);
&html_join_success;
}
else {
&html_join_failure($status);
}

}

The problem is that none of the code in red does anything - if your logged in as WBK73G or default or imadummie, it always puts the value of $rec{'Callsign'} of who you are logged in as and not the randomly generated string.

Any ideas?


Thanks,



Michael DeLong
Quote Reply
Re: UserID Field Problems In reply to
Okay, I figured out about where the problem is, but I don't have the foggiest clue as to what's wrong or how to fix it.

The problem isn't just with my new subroutine, but even the add_record sub in the .cgi file is doing it too. What happens is that no matter how I send the Callsign field (userid field) to the database, it always comes out as the person you are logged in as.

Please help - my organization is depending on this script to work.



Michael DeLong
Quote Reply
Re: UserID Field Problems In reply to
What other information do yall need to know?



Michael DeLong
Quote Reply
Re: UserID Field Problems In reply to
Okay, for the few of you who have taken the time to look at this post...I have some new information.

I was at the Unofficial DBMan FAQ (webmagic.hypermart.net) and went to the trouble shooting page. I saw a link to something called "The userid is entered into a field where I don't want it". I checked it out and it said to set auth_user_field to -1 if this is happening. So I did. Now what happens is that in the add_success page, the table that has the record information is blank. However, when I log in as administration and go look at the validation page, it shows the callsign correctly. The other problem is that the new user can't modify his/her information - it always shows "Search Failed".
I can live with none of the information showing in the add_success page, but for the user to not be able to modify his/her information is a big no-no. If someone could please help me fix the latter problem, I'd be all too greatful. If someone could help me fix both problems, I'd be in their debt forever.

So please, HELP!



Michael DeLong
Quote Reply
Re: UserID Field Problems In reply to
Hi Michael, I'd be more than happy to look at the files and see if I can spot anything which may be causing the problem in your db files. I can't do it blindly though. I really do need to see/review the documents in order to try locating problem areas.

Michael, if you're hesitant on posting your urls to the forum, please use the private message feature at the top of the forum screens to send me a note privately. Save each of your files as regular text files and upload to an area of your server where the files can be viewed from the web. Send a note with the urls.


Quote Reply
Re: UserID Field Problems In reply to
Thanks Karen - I was starting to worry that I was gonna be left in the dark again!

I've renamed the files:

auth.pl.txt
default.cfg.txt
default.count.txt
default.db.txt
default.log.txt
default.pass.txt
html.pl (bewarned - 200KB file)
roster.cgi.txt

Location: http://webknights.hypermart.net/cgi-bin/roster/
I'll be leaving those files on the server for only three days after this problem is solved (for those of you who like to keep reference of problems you might consider as a useful reference); after that - I'll delete them for security and disk space.

Again, thank you so much for your reply Karen!

Regards,



Michael DeLong
Quote Reply
Re: UserID Field Problems In reply to
Hi Michael,

I am getting 500 server errors when attempting to access your html.pl file - Please save the following files as text files and upload them somewhere outside your cgi-bin - apparently the cgi-bin directory is going to let anything run as a script because I cannot access your roster.cgi.txt file either - the script loads instead of being able to display the text.

html.pl.txt
roster.cgi.txt
default.cfg.txt - this file I can view but it would be easier having all three files in the same location.

Correction needed in default.cfg:
$admin_email = 'WBK73G\@webknights.hypermart.net';
$admin_email1 = 'serio\@purdue.edu';


The other text files can be removed - I only need to see the three files.



Quote Reply
Re: UserID Field Problems In reply to
Okay, thanks...I've renamed them to the following:

defaultcfg.txt
defaultcount.txt
defaultdb.txt
defaultlog.txt
defaultpass.txt
htmlpl.txt
rostercgi.txt

and moved them to:

http://webknights.hypermart.net

Does that do the trick?

Michael DeLong
Quote Reply
Re: UserID Field Problems In reply to
Hi Michael, not sure whether this could be a cause of your problems however, you've indicated in your default.cfg file that the auth user field is not used but then you're calling for the auth user field throughout the scripts.

# Auth user field. This is the field position in the database used for storing
# the userid who owns the record. Set to -1 if not used.
$auth_user_field = -1;

if (($db_userid eq $rec{$db_cols[$auth_user_field]}) || $in{'add_form'} || $per_admin) {
print qq|

# Set the userid to the logged in user.
($auth_user_field >= 0) and ($in{$db_cols[$auth_user_field]} = $db_userid);

I think you're using Callsign as the auth user field. In that case, you would need to identify
$auth_user_field = 7;

Give that a try (fix the email addresses too :-) and let me know whether that changes anything.

Quote Reply
Re: UserID Field Problems In reply to
Karen, in a previous post above I wrote:

I was at the Unofficial DBMan FAQ (webmagic.hypermart.net) and went to the trouble shooting page. I saw a link to something called "The userid is entered into a field where I don't want it". I checked it out and it said to set auth_user_field to -1 if this is happening. So I did. Now what happens is that in the add_success page, the table that has the record information is blank. However, when I log in as administration and go look at the validation page, it shows the callsign correctly. The other problem is that the new user can't modify his/her information - it always shows "Search Failed".
I can live with none of the information showing in the add_success page, but for the user to not be able to modify his/her information is a big no-no. If someone could please help me fix the latter problem, I'd be all too greatful. If someone could help me fix both problems, I'd be in their debt forever.

-----

The unofficial faq suggested I set it to -1. Since then, the callsign is generated as it should and the userid isn't always the value of callsign as it was before. The only problem now is that the new member can't modify their information and the join_success page isn't showing the record (everything is blank).

Michael DeLong
Quote Reply
Re: UserID Field Problems In reply to
Also, if you need admin access, just msg me and I'll contact you privately and give it to you.

Michael DeLong
Quote Reply
Re: UserID Field Problems In reply to
Karen,

I was just wondering if you're okay - haven't seen you in a while.