[FX.php List] Variables and Sessions

Laura Long laural at ultimate-products.com
Sun Feb 12 10:29:51 MST 2006


Hi, 

I am a php programmer in training, lol... I have a question.  I have a
database that holds all of my users.  I have a "Login" database that
works with my php page and creates a new record every time someone logs
in.  I pass an id, the username and the password to create a string
which is used as a key to match a record in the company database.  Then
the login page does lookups based on that key and brings in all of the
users information to that database.  That all works fine.

Here is where I get stuck.  I would like to begin a session on the
Results page that will use the value in one of the fields in the login
database (the field is called services), and then the rest of my php
site will reference the value of services to bring in information.  I
can begin a session and set the variable to one of the 3 fields that was
in the login form, or to a static value, but I do not know how to
reference the services field in the login database to use as the value
for my session.  I hope this makes sense, I will post the code below:

Login Page: Here is the portion of code that contains my form:

<form action="result.php" method="post">

                <tr>
                  <td align=right colspan="3">
                    <div align="left">Please enter your <i>Username</i>
and <i>Password</i>
                      to access Work Life Services. </div>
                  </td>
                </tr>
                <tbody>
                <tr>
                  <td align=right width="64">Username:</td>
                  <td align=left colspan=2 width="211">
                    <input type=text name=username value="" size=20>
                  </td>
                </tr>
                <tr>
                  <td align=right width="64">Password:</td>
                  <td align=left colspan=2 width="211">
                    <input type=password name=password value="" size=20>
                  </td>
                </tr>
                <tr>
                  <td align=right valign=top width="64">&nbsp;</td>
                  <td align=right colspan=2 width="211">
                  <input type="hidden" name="idUser" value="1045">
                    <input type="submit" name="Submit" value="Submit">
                  </td>
                </tr>
                </tbody>
              </form>

Result Page: where the session is supposed to be set: where usename is
registered, I would like to pull the value of the field services:

<?php
session_start( );

include_once('../FX/FX.php');
include_once('../FX/server_data.php');

$username=$_POST['username'];
$password=$_POST['password'];
$idEAP=$_POST['idEAP'];
$login=new FX($serverIP,$webCompanionPort,'FMPro7');
$login->SetDBData('multiAdvantage.fp7','Login');
$login->SetDBPassword('password','Webuser');
$login->AddDBParam('idEAP',$idEAP);
$login->AddDBParam('username',$username);
$login->AddDBParam('password',$password);
$loginResult=$login->FMNew();
?>

<html>
<head>
<title>Results</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="webstyle.css" rel="stylesheet" type="text/css">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<?php
session_register($username);
print "Your name is: ";
print $username;
?><br>


Error Code: <?php echo $loginResult['errorCode']; ?> <br>
Found Count: <?php echo $loginResult['foundCount']; ?> <br>
<table width="400" border="0" align="center" cellpadding="2"
cellspacing="2">
  <tr>
    <td>Username</td>
    <td>Password</td>
  </tr>
<?php foreach($loginResult['data'] as $key=>$loginData){ ?>
  <tr>
    <td><? echo $loginData['username'][0]; ?>&nbsp;&nbsp;</td>
    <td><? echo $loginData['password'][0]; ?>&nbsp;</td>
  </tr>
<? } ?>
</table>
<a href="session2.php">Continue</a>
</body>
</html>



More information about the FX.php_List mailing list