This topic is locked

How to display user pic next to "Logged on as" message

11/13/2013 11:55:36 AM
PHPRunner Tips and Tricks
Sergey Kornilov admin

Lets consider the situation when your login tables stores path to user picture. Sample database structure:

ID Username Password Pic

--------------------------

1 admin xxxx https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=21581&image=1&table=forumtopics

2 user xxxx https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=21581&image=2&table=forumtopics

...



Here is how you can display this picture as a part of 'Logged on as' message.

  1. In AfterSuccessfulLogin event save path to image file in session variable:

$_SESSION["pic"]=$data["Pic"];



2. Then in BeforeDisplay event of the page where you need to display this picture use the following:

$xt->assign("username","<img height=24x width=24px src='".$_SESSION["pic"]."'> ".$_SESSION["UserName"]);


Modify width and height of the page accordingly. You will have to add this code to each BeforeDisplay event of those pages where you want to display this picture.