Gossamer Forum
Home : Products : DBMan : Customization :

Force signup code not working.

Quote Reply
Force signup code not working.
This is in reference to force Add at signup, not force signup. Sorry! See.

http://www.gossamer-threads.com/scripts/forum/resources/Forum12/HTML/001118.html

For some reason the line

%rec = &get_record($db_userid);

doesn't do what it's supposed to. In the config file I've got

$db_key = 'Rec_ID';

which should be unique, since I have

$auth_signup = 1;

and

$auth_user_field = 0;

which is the field number for Rec_ID

I can't see what is amiss.

-Brian


[This message has been edited by bboru (edited October 02, 1999).]
Quote Reply
Re: Force signup code not working. In reply to
Yeah, I don't blame you. I've been confusing myself.Sorry.

This I know, regardless of whether one has a record or not, one goes to the main menu.

the code is

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

Both of the earlier print experiments yielded the correct user and record names (both the same for a given user).

Quote Reply
Re: Force signup code not working. In reply to
I need for you to copy your .cfg file to a web-accessible directory (one where you would place html files) and rename it to default_cfg.txt. Then come back here and tell me where it is.

Also, please post the code you used for the "force add" this thread. Include the name of the subroutine where it is and the lines just before and after it.


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





Quote Reply
Re: Force signup code not working. In reply to
The config is at
cellar8.com/seminar/default_cfg.txt

The code for the beginning of sub home_html is

sub html_home {
# --------------------------------------------------------
# The database manager home page.

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

&html_print_headers;

Thanks.
-Brian

[This message has been edited by bboru (edited October 02, 1999).]
Quote Reply
Re: Force signup code not working. In reply to
I added a record to your database to check it out. Please delete it. Smile

I don't know what the problem could be. It uses the same code the code for modifying records and that works just fine.

We can try some debugging. Comment out the code for the "forced add" and, in sub html_home, (within a print statement) add

Code:
Userid = $db_userid

See if it prints out the login name.


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





Quote Reply
Re: Force signup code not working. In reply to
I guess I wasn't clear.
Yes, the code seems to force one to the add page, but it does so even when a record already exists and it does so for the admin, too.

I commented out the force-add code and inserted

print Userid = $db_userid;

An error resulted:

Can't modify constant item in scalar assignment at ./../cgi-local/glahtml.pl line 333, near "$db_userid;"
Quote Reply
Re: Force signup code not working. In reply to
The Userid = $db_userid needs to be within a print statement.

Try this --

Somewhere after your title prints out on sub html_home, add

Code:
print qq|Userid = $db_userid|;



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





Quote Reply
Re: Force signup code not working. In reply to
Ok, it prints the correct user ID, that is, the person's created user name.

-Brian
Quote Reply
Re: Force signup code not working. In reply to
Good. That's working.

Now put back the line:

Code:
%rec = &get_record($db_userid);

at the beginning of the subroutine. Change

Code:
print qq|Userid = $db_userid|;

to

Code:
print qq|Userid = $rec{'Rec_ID'}|;

Be sure to log on with a username that has a record in the database.


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





Quote Reply
Re: Force signup code not working. In reply to
Ok, this time I'm seeing

Userid =

No user or record names. This was for a user who *does* have a record.

-Brian
Quote Reply
Re: Force signup code not working. In reply to
Correction. I left some code hanging.

The user name *does* display if there's a record.

But when I have the following add code in place, I still go to the main menu. The reason I was going to the add before was that I had somehow left in the call for the add form when I thought I had cut it out.(So this would lead me to the add form regardless of whether there was a record.)

# The database manager home page.
%rec = &get_record($db_userid);
if ((!%rec) && (!$per_admin)) {
&html_add_form;
return;
}


&html_print_headers;
Quote Reply
Re: Force signup code not working. In reply to
For some reason, it's not getting the record.

Change

Code:
%rec = &get_record($db_userid);

to

Code:
$in{$db_key} = $db_userid;
($status,@hits) = &query('view'};
%rec = &array_to_hash(0,@hits);

Leave the line

Code:
print qq|Userid = $rec{'Rec_ID'}|;

where it is. See what happens then.


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





Quote Reply
Re: Force signup code not working. In reply to
Wait a minute. I'm confused now.

What code do you have in sub html_home?
What happens when a user who has a record logs on?
What happens when a user who doesn't have a record logs on?


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





Quote Reply
Re: Force signup code not working. In reply to
I tried the latest code you offered. (I just now saw it) but got an error.

Did you mean to write?:

$in{$db_key} = $db_userid;
($status,@hits) = &query('view');
%rec = &array_to_hash(0,@hits);

I tried this and stopped the error but got nothing but Userid=

After flushing my browser cache and looking again, I'm seeing printed
$db_userid
but not
$rec{'Rec_ID'}

-Brian



[This message has been edited by bboru (edited October 02, 1999).]
Quote Reply
Re: Force signup code not working. In reply to
I'm still confused.

What happens when you have the following code active in sub html_home?

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

My understanding is that, when you had that code earlier today, the user was sent to the add form no matter what. Now it seems that the user is not sent to the add form, no matter what.

I don't understand.


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





Quote Reply
Re: Force signup code not working. In reply to
What happens is I always end up at the main page and not the add page. When I inserted the code to print userid and record ID, the userid always printed, but the record ID only printed if there was an existing record.
Quote Reply
Re: Force signup code not working. In reply to
I really don't know what the problem is, then. With the same code, different things are happening. I just don't get it.

Can I look at your current html file? (This is a last-ditch effort to see if there is something that hasn't occurred to me before.)




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





Quote Reply
Re: Force signup code not working. In reply to
Sure thing. You have the patience of a reference librarian. Remarkable, indeed! Many thanks for the effort.

http://cellar8.com/seminar/html.txt
Quote Reply
Re: Force signup code not working. In reply to
I think I'm going to need you to keep my userid and password in the file at least until we get this worked out. Smile

Let's try this.

Instead of

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

Use

Code:
%rec = &get_record($db_userid);
unless ($rec{'Reg_ID'}) {
&html_add_form;
return;
}

I just added a record and then logged in again. This time the Reg_ID showed up on the page. We're making progress! Smile


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





Quote Reply
Re: Force signup code not working. In reply to
Halleluja! A miracle indeed! It works both as you wrote it and with my admin modification. Thanks a zillion.
-Brian.
Quote Reply
Re: Force signup code not working. In reply to
Whew! Smile

You said something earlier about my patience. It's not really patience, it's stubborness. I can't take it when a script gets the better of me. Smile

You're welcome!


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