This topic is locked

Logon Redirect and Passing Variables

10/26/2009 12:35:04 PM
PHPRunner General questions
B
beachldy author

I'm very new to PHPRunner and am trying to learn the ropes.
I have a table in MySql(AgencyName,AgencyLicNr(which is also the user's Logon), and AgencyPwd)
What I need to do after successful logon is this:
If logon is successful, grab AgencyName and AgencyLicNr as session variables

I added some code to the Logon page (after successful logon)

---------

str = "select * from Agency where AgencyLicNr='" & username & "' and AgencyPwd='" & password "'"

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

rstmp.open str,dbConnection
if not rstmp.eof then

Session("AgencyLicNr") = rstmp("AgencyLicNr")

Session("AgencyName") = rstmp("AgencyName")

end if
---------

The variables aren't being saved, I don't think, as on another ADD Page (Add Item page), I put the default value to the field AgencyName

Session("AgencyName")
The Agency table has AgencyLicNr and AgencyName, as does the Items table. The user shouldn't have to add these things if it's already gotten from their logon page.

Sergey Kornilov admin 10/26/2009

It appears you trying to use ASP code in PHPRunner.
Here is the example you can use:

http://www.xlinesoft.com/phprunner/docs/save_user_data_in_session_variables.htm
There is no need to run SQL query as all user record fields are passed as parameter.

B
beachldy author 10/26/2009

AWECSOME, that worked! I was trying to query the item using a regular $variable instead (from a sql query) and was getting "undefined variable" error.
I WAS trying:
$userID = $_SESSION['UserID'];

$result = mysql_query("SELECT AgencyName FROM Agency WHERE AgencyLicNr='$username'");

$AgencyName = mysql_result ($result, 0, 0);
I could get it to return a value with an echo but got errors setting the Default value on the form. Out of curiousity, why couldn't the $AgencyName variable be used?

J
Jane 10/28/2009

Hi,
$AgencyName is not global variable.

You can save this value in the session variable and then use this session variable as default value:

$_SESSION["AgencyName"] = $AgencyName;