This topic is locked

Session ?

1/21/2009 4:49:24 PM
PHPRunner General questions
W
wildwally author

OK, here I am again. When dealing with the default value and session userid is it possible for the default value to return any value from the user list.
$values["MyQP"]=$_SESSION["UserID"];
The line above is what I have tried , and it doesn't work as I want it to. I'm wanting the field to show the default contact person that the user selected when he registered. While still having the ability to select a different person if they need to. The table name containing all the information is called 'users', and the field is 'MyQP'.
I have the list working like it should, and it filters out everyone through the use of WHERE clause (works nicely). Just need the default to work.
I was thinking about making this a session variable if possible, but can't find anything on how to do that.

A
alang 1/21/2009

You can create a session variable in your login (after successful) event code something like:
global $conn;
$query = "SELECT MyQP FROM users WHERE <yr field for username> = '{$username}'";

$res = db_query($query, $conn);

$row = db_fetch_numarray($res);

$_SESSION["MyQP"] = $row[0];
Then anywhere in your code, you can reference this:
$values["MyQP"]=$_SESSION["MyQP"];

W
wildwally author 1/22/2009