This topic is locked
[SOLVED]

 Getting Default Value data from another table

12/8/2011 6:54:19 PM
PHPRunner General questions
lefty author

I need to populate some default values on a table called ex. Book. I have a users table that has the name of the person group and student #. In asp see the following code below . I just grabbed the users table set the userid to session userid and sessioned all the fields that I needed from the users table. In PhP I am having problems : see below asp code......
str = "select * from Employees where Userid='" & Session("UserID") & "'"

Set rsTemp = server.CreateObject("ADODB.Recordset")

rsTemp.open str, dbConnection

Session("employeenumber")= rsTemp("employeenumber")

Session("Firstname") = rsTemp("Firstname")

Session("Lastname") = rsTemp("Lastname")

Session("DepartmentName") = rsTemp("DepartmentName")

Session("EmailName") = rsTemp("EmailName")

rsTemp.close : set rsTemp = nothing
Just thought I would start it as they logged in so it was global. Any ideas . this is blowing out " undefined $_Session variable error. example default value would be $_Session["fldnum"] returns null value or nothing.
PHP
function AfterSuccessfulLogin($username, $password, $data)
{
$_SESSION["fldnum"] = $data["fldnum"];

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

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

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

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

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

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

}

  1. Do I need to call the db here even after login
  2. The login table has all the field above
  3. To you need to start session and end session here or does phprunner do that auto.
  4. DO I need sql statement instead?

    Thanks for the replies!

C
cgphp 12/9/2011

Where/When do you get the "undefined $_SESSION variable" error ?

lefty author 12/10/2011

Okay ; fixed Undefined variable . typed data field incorrect in default value field. But now when going to add page the field is blank. Should be populated with the session data. ex. $_Session["fldfirst"] = should return data from the users table .

lefty author 12/11/2011

Sql query worked . Still don't know why above would not work? Was called upon successfull login.
Working Sql:
global $conn;

$strSQLSelect = "SELECT fldgroup, fldfirst, fldlast, fldnum, fldteam FROM users WHERE userid = '".$_SESSION["UserID"]."'";

$rsSelect = db_query($strSQLSelect,$conn);

$data=db_fetch_array($rsSelect);
$_SESSION["fldfirst"] = $data["fldfirst"];

C
cgphp 12/11/2011

In the "Process record values" event of the Add page, enter this code:

$values['fldfirst'] = $_SESSION["fldfirst"];