This topic is locked

Dynamic Pages

6/21/2006 10:07:19 AM
PHPRunner General questions
B
bmak author

Hello,
Is there any information available on how I would add dynamic elements to a web page generated by PHPrunner?
What I have in mind is a user-specific greetings page that welcomes them back by name "Hello <uname>, welcome back" and then confirms the last time they logged into the system?
Can I add dynamic elements to a project in this way?
Thanks
bmak

J
Jane 6/22/2006

Hi,
you can do it using events on the Events tab in the PHPRunner.

Here is a sample code for this event:

global $conn;

$strSQL = "select * from table1 where userid = ".$_SESSION["UserID"];

$rs = db_query($strSQL,$conn);

$data=db_fetch_array($rs);
echo "Hello".$data["username"]."welcome back";



where table1 is your actual table name, username is your actual field name in which username is stored.
To add last time user logged into the system create a log table in which this data will be stored. Then insert userid, username and timestamp into log table after user logged in. Use Insert a record into another table action as example for this event.

To display last time user logged into sistem use following sample code:

global $conn;

$str = "select * from logtable where userid = ".$_SESSION["UserID"];

$rslog = db_query($str, $conn);

$datalog = db_fetch_array($rslog);

echo "last time user logged into sistem ".$data["timestamp"];



where timestamp is you actual field name.

B
bmak author 6/22/2006

HI Jane,
This is great, thanks very much for your help.
Kind Regards
bmak

B
bmak author 6/22/2006

Hi,

you can do it using events on the Events tab in the PHPRunner.

Here is a sample code for this event:
where table1 is your actual table name, username is your actual field name in which username is stored.
To add last time user logged into the system create a log table in which this data will be stored. Then insert userid, username and timestamp into log table after user logged in. Use Insert a record into another table action as example for this event.

To display last time user logged into sistem use following sample code:
where timestamp is you actual field name.


Hello,
After sending this question yesterday I took a look at the logistics of getting this to work. My initial thought was that it would probably be better to start fresh as I had been working the registration and login through a single table. If I were to include a 'last logged in' function then I would, as you point out, require two tables, one for the regsitration process and another as the logged in loggin table.
Am I correct in thinking that the regsitration process would centre around the existing users table but that the login process would then focus on the logging in table rather then the one used for registration?
Would you recommend that these tables have a foreign key relationship?
Thanks
bmak

J
Jane 6/22/2006

Sure you can use single table Users and add new field, for example last_logged, in it and then modify event code in the following way:

global $conn;

$strSQL = "select * from table1 where userid = ".$_SESSION["UserID"];

$rs = db_query($strSQL,$conn);

$data=db_fetch_array($rs);
echo "Hello".$data["username"]."welcome back
last time you logged into sistem ".$data["last_logged"];