This topic is locked
[SOLVED]

  Table primary key into session variable

2/2/2012 10:46:19 AM
PHPRunner General questions
S
Sergej author

Hi again!

I would like to do the following: created session variables from several fields from login table...but couldn't force id - field - which is primary key for the login table to populate session variable. All the other fields are populated ok - (after sucessful login i get username, country, firm...but no id - i would like to use that id to automatically populate user id field of another tables in add/edit mode
Here is what i add in Aftersucessful login event

$_SESSION["username"] = $data["username"];

$_SESSION["firm"] = $data["firm"];

$_SESSION["first name"] = $data["first name"];

$_SESSION["last name"] = $data["last name"];

$_SESSION["country"] = $data["country"];

$_SESSION["id"] = $data["id"];
and put into the appropriate Add page

in edit as mode:

read only - default value $_SESSION["id"]
when i tryit with all other session variables it works but not with id field...i even entered new field in the table UserID (type varchar, while id is numeric) and in sqlquery - i defined this field to just take the value from id field, but got nowhere.
Any ideas?

Big thnx to all

C
cgphp 2/2/2012

Enter the following code in the "After successful login" event:

print_r($data);

exit();


and check the outoput.

S
Sergej author 2/2/2012

Array ( [id] => 9 [password] => eecf59c84654bf3367339e9c7a08c6a6 [username] => Sergej [email] => sergej@info-ing.com [firm] => Infoing - Consult d.o.o. [phone] => [fax] => [mobile] => [country] => CROATIA [first name] => Sergej [last name] => Karov [active] => 1 [TCIUserID] => )

i get the id by using your ocde but cannot (don't know how rather) to assigne this specific value (9) to add/edit pages of another tables by using S_SESSION["id"]

Sergey Kornilov admin 2/3/2012

Once $_SESSION["id"] is assigned you can use it as default value for any field in any table.

S
Sergej author 2/3/2012



Once $_SESSION["id"] is assigned you can use it as default value for any field in any table.



Yes...now it is working though everything remained practicaly unchanged...thank you all for your help