Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

question about user registration and returning to add link

Quote Reply
question about user registration and returning to add link
I have added the mod to require a user to register before adding a link, however, I would really like to be able to return the person to the add form for the category they were trying to add a link to. Since the category ID isn't passed on to the register link from the signup form or the validate link once they have signed up, all that get's lost, even though it appears in the url on the page where they login. Also, when they log in to the system after clicking on an add link button, since a cookie hasn't been set yet, they are still just back to the you have been successfully logged in screen. And since we are at it, has there been much done in the way of personalization, so if they are logged in, I can dynamically list their name somewhere (even on static pages) and add a logout function as well. Anyone gotten something like this to work yet.
Quote Reply
Re: question about user registration and returning to add link In reply to
I still have some problem, too, with the user-reg:
I login and choose home and find the button "login" again ??? So why this is no session till i close the window or click on logout? If i click logout, i got an param ... error.
I have tested as editor; thats clear, but what should be as admin; nothing happens if i log in as an admin ?

How can i meld the user and the link; possible with a new field for a link with the user-ID in it or with a table for the user save all the links he put in.

As the normal links-functions these thoughts are normally not neccessary, but i think there are so many other things than a boring linkengine we could do with links.
Robert

Quote Reply
Re: question about user registration and returning to add link In reply to
umm.. my mod right?

well.. i found out there was a bug in internet explorer.. i have no clue what is wrong.. it has to do with the cookie being set.. i looked at it for awhile and only noticed one of the two cookies being set..

jerry

Quote Reply
Re: question about user registration and returning to add link In reply to
I believe it is your mod. IIRC, it is from here
http://www.gossamer-threads.com/scripts/forum/resources/Forum9/HTML/000497.html

Here is the problem that I see. When you go to a category and click on add link, it shows a url like this... /cgi-bin/add.cgi?ID=20 and when you click you go to a url like this...
/cgi-bin/user.cgi?to=/cgi-bin/add.cgi?ID=20
which appears to be correct. But unless I'm logged into the system, which I'm guessing most people won't be, I either have to log in or sign up.

If I log in, the ID=20 isn't passed anywhere, either in the signup area (ie, maybe it should be a hidden field) or in the register link (as a parameter on the link url) which shows something like /cgi-bin/user.cgi?signup_form=1 At least I don't see it anywhere in the source of the signup page that results from clicking on the add link button. It seems like it's only going to work if you are already logged in, and then it brings you right to where you need to be. I'm guessing somehow this ID=X needs to get passed around some other forms especially if you are signing up and have to wait for the email and then enter the validation code, which appears to have absolutely no reference to the ID.

Also, I'm using Netscape in this case, haven't gotten to testing on IE yet.

Jerry


Quote Reply
Re: question about user registration and returning to add link In reply to
Well, I think after about six hours I have it figured out now, and there were a bunch of changes, but it does seem to work so far. These changes were all made AFTER I made the changes in Widgetz mod referred to in the url listed above, and I somewhat ignored the "to" part of passing the info around.. I have only tested it with one id so far, but until I can do more, I thought I would post all the changes here to see if someone else might be able to make sure it all appears correct. I have only tested it in NN so I don't know if there are any problems in IE that Widgetz mentioned. And I'm not an expert programmer, so no guarantees :)

first for the programs

in add.cgi

in sub main - add this
my $new_id = $in->param('ID');
after this
my $s = $in->param('s') || $in->cookie('s');

and change this line
print $in->redirect("$LINKS{db_cgi_url}/user.cgi?to=$encurl") and return;
to this line
print $in->redirect("$LINKS{db_cgi_url}/user.cgi?to=$encurl&ID=$new_id") and return;


in user.cgi

in sub main add this line
my $new_id = $in->param('ID');
after this line
my $dynamic = $in->param('d') ? $in : undef;

change this line
&site_html_login_form ( { Username => $username }, $dynamic);
to this line
&site_html_login_form ( { Username => $username, ID => $new_id }, $dynamic);

change this line
&site_html_signup_form ( { Username => '', Password => '', Email => '' }, $dynamic);
to this line
&site_html_signup_form ( { Username => '', Password => '', Email => '', ID => $new_id }, $dynamic);

change this line
&site_html_validate_form ( {}, $dynamic);
to this line
&site_html_validate_form ( { ID => $new_id }, $dynamic);


in sub login_user

add this line
if ($in->param('ID')) { my $new_id = $in->param('ID') };
after
my $pass = $in->param('Password');

comment out these lines

if ($in->param('to')) {
print $in->redirect( -cookie => [$session_cookie, $user_cookie], -uri => ("$LINKS{build_root_url}" . $in->param('to')) );
}

and add these lines instead

if ($in->param('ID')) {
print $in->redirect( -cookie => [$session_cookie, $user_cookie], -uri => ("$LINKS{build_root_url}/cgi-bin/add.cgi?ID=" . $in->param('ID')) );
}


in sub signup_user

add this line
my $new_id = $in->param('ID');
after this line
my $in_r = &cgi_to_hash ($in);

in sub validate_user

add this line
my $new_id = $in->param('ID');
after this line
my $hits = $db->query ( { Validation => $code, ww => 1 } );


in sub validate_user

add this line
my $new_id = $in->param('ID');
after this line
my ($in, $dynamic) = @_;

change this line
&site_html_validate_success ($user, $dynamic);
to this line
&site_html_validate_success ( { ID => $new_id }, $dynamic);

now for the templates


in login.html

add this after the main <form> tag

<%if ID%>
<input type="hidden" name="ID" value="<%ID%>">
<%endif%>

and change the link for registering to add the ID like this line

Click here to <a href="<_cgi_url%>/user.cgi?signup_form=1
<%if ID%>
&ID=<%ID%>
<%endif%>
">register</a>


add to signup_form.html after the main <form> tag

<%if ID%>
<input type="hidden" name="ID" value="<%ID%>">
<%endif%>


in signup_success.html

change the link for validating like this line

need to enter a <a href="<_cgi_url%>/user.cgi?validate=1
<%if ID%>
&ID=<%ID%>
<%endif%>
">validation code</a>.


in validate_form.html add this after the main <form> tag

<%if ID%>
<input type="hidden" name="ID" value="<%ID%>">
<%endif%>

in validate_success.html

after this line
<p>Thank you, your account is now activated!</p>

add this

<%if ID%>
<p>Click <a href="/cgi-bin/user.cgi?login_user&ID=<%ID%>">here</a> to login and add your link.</p>
<%endif%>

And that should do it. Again, if anyone else is experiencing the same problems and finds that this solves them, please let us know.

Jerry