Forums

PHP

This topic is locked

phakt, getting user details after login

Posted 14 Nov 2001 08:55:18
1
has voted
14 Nov 2001 08:55:18 tenabrae na posted:
i've made a site with a user registration and login page that work just fine... what i can't figure out is how, after the user logs in, to retrieve their user information and display it.

i've used the loginuserPHP behaviour to login the user, what i can't figure out is where (if) the login information is stored, so i can retrieve it, and use it in a recordset to display the user's profile after they login.

i'm new to PHP and phakt so i'm not comfident hand-coding at the moment, any help would be appreciated as to how i go about solving my problem.

Replies

Replied 14 Nov 2001 21:49:39
14 Nov 2001 21:49:39 Ryan Schwiebert replied:
On the page to display this information you have a few options.

If all you want to display is the username, just insert this php code:
<?php echo $KT_Username; ?>

If you want to display more, you need to create an SQL query with $KT_Username as the filter. To do this just create a recordset and select the table with the user info. Next use the filter of "whatever the username field is" set it equal to "PHP Variable" and type $KT_Username.

Now you can drag any of the fields you selected into your page, and they will display.

Hope that helps! Cheers!

Ryan

Replied 15 Nov 2001 06:20:55
15 Nov 2001 06:20:55 tenabrae na replied:
yup, that did the trick, thanks much.

Replied 02 Dec 2001 20:10:54
02 Dec 2001 20:10:54 RJ Skypala replied:
Hey, I get the message


Warning: Undefined variable: KT_username in D:\kyi\newsadd.php on line 115

If anyone can help, I would appreciate it.


thanks
-RJ
Replied 04 Dec 2001 12:42:27
04 Dec 2001 12:42:27 Jose Ortega replied:
Hello!
I am trying to solve the same problem as described by tenabrae. Somehow I don't seem to be able to get the solution posted by ryans to work though.
I have created a login page with the text fields login and password using the PHAkt User Login behavior. Now I want to hand on the content of login to the next page, so that I can either display it there or use it as a filter? The data seems to be stored in a session variable called $KT_Username as pointed out by ryans. But when I put <?php echo $KT_Username; ?>
on my welcome page nothing is displayed. How can I check if anything has been assigned to $KT_Username or do I have to add some more code to be able to use that variable. (Sorry, if this is something very basic I should know - but I'm still very new to PHP.)
The login behavior and access levels work fine. I can also add a recordset from the table where I store login names and passwords. As soon as I add the filter though I get no results.

I'd be very grateful for any suggestions or sample code I could use.

Thx Jose
Replied 04 Dec 2001 15:07:39
04 Dec 2001 15:07:39 Keith Slater replied:
At the top of the page inside of one of the PHP codes try adding this:
session_start();


Keith Slater
Replied 04 Dec 2001 22:38:08
04 Dec 2001 22:38:08 Jose Ortega replied:
Thanks a lot, Keith! That helped!

Jose
Replied 06 Dec 2001 22:29:59
06 Dec 2001 22:29:59 Michael O'Neill replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hey, I get the message


Warning: Undefined variable: KT_username in D:\kyi\newsadd.php on line 115

If anyone can help, I would appreciate it.


thanks
-RJ
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

You've maybe figured this out already, but it should be KT_Username (note the capital U). Variables in PHP are case sensitive.
Hope this helps.
Mike.
Replied 03 Feb 2002 18:15:14
03 Feb 2002 18:15:14 web warrior replied:
Ok, found (another) solution:

Create a enviroment variable in the databindings, a session called "KT_Username".

Create a recordset, (rs_user) than filter the field with the unique username : session / KT_Username.

Now drag & drop the fieldname from the recordset on any page after a succesfull login, and the logged in name is selected from the database..

grtz..

Lars J.


Replied 05 Feb 2002 15:24:49
05 Feb 2002 15:24:49 Paul Lacey replied:
<font face='Verdana'>Hi

Thanks for this, after going through this topic it works for me too.

But can anyone please answer this question:

Although it works, can anyone explain where the KT_Username comes from or stands for? Its not a variable I have created at any point. Sorry to sound dumb but I would feel better if I understood why this works.

thanks

Paul Lacey

ps PHacT is great and I can't wait to get my hands on the NeXtension just ordered!</font id='Verdana'>

Replied 05 Feb 2002 15:32:55
05 Feb 2002 15:32:55 Paul Lacey replied:
Hi

sorry I forgot to ask in the last post,

Is there anyway I can get the session to refresh its details as I have a page that uses an update behaviour to upgrade a users access level from 1, to 2. This works fine, but the user has to log out then back in before the pages recognise this change.

I would be forever grateful if anyone can help.

cheers

Paul Lacey

Replied 05 Feb 2002 16:08:43
05 Feb 2002 16:08:43 Jose Ortega replied:
Hi Paul!

Ad question 1: When you add the LoginUser behavior the following code is added to your page:

*** Start the session
session_start();
// *** Validate request to log in to this site.
$KT_LoginAction = $PHP_SELF;
...
if (isset($login)) {
$KT_valUsername=$login;
...
// username and password match - this is a valid user
$KT_Username=$KT_valUsername;
session_register("KT_Username";

$login is the name of the form field where the visitor has to enter his login-name, the input is assigned to the variable $KT_valUsername. If the login-name exists in the database it is a valid login and assigned to $KT_Username--which is then registered as a session variable.


Ad question 2: Just a guess, but maybe try to unregister and then reregister the session variable(s).

Hope that helps!

Jose
Replied 06 Feb 2002 15:46:26
06 Feb 2002 15:46:26 Paul Lacey replied:
thanks joseortega

cheers for the explanation, still trying to somehow refresh the session though. If I find the solution I will post it on here in answer to my own question.

thanks again

Paul

Reply to this topic