sitewes Posted August 3, 2009 Share Posted August 3, 2009 Hello.. I am trying to display Welcome $clientsdetails.firstname on my main website when client is logged into to whmcs.. I have this on my main website (/index.php) === <?php require("account/dbconnect.php"); require("account/includes/functions.php"); require("account/includes/clientareafunctions.php"); ?> === This is how I am calling the info on /index.php === <?php if ($_SESSION['uid']) { echo("<div class='grid_9 clientarea'>Welcome back <strong>"); echo("$clientsdetails.firstname"); echo("</strong>!</div>"); } else { echo("<div class='grid_9 clientarea'>Welcome Guest! Please <a href='#TB_inline?height=125&width=400&inlineId=Thickbox-ClientLogin' class='thickbox' title='Client Area Login'>Login</a> or <a href='account/register.php'>Register</a></div>"); } ?> === When user is not logged in, it does display the Welcome Guest! But when they are logged in... it only displays: Welcome .firstname! === Please let me know what I have done wrong, I need to call info from the users database info if possible. Thanks! 0 Quote Link to comment Share on other sites More sharing options...
sitewes Posted August 3, 2009 Author Share Posted August 3, 2009 I am running Version: 4.0.2 0 Quote Link to comment Share on other sites More sharing options...
lysenshi Posted August 3, 2009 Share Posted August 3, 2009 Simply speaking, $clientsdetails.firstname is not a variable that WHMCS will load in every page, there should be a code to load some value into the variable. Just use the following code in the php file: <?php require("account/dbconnect.php"); require("account/includes/functions.php"); //Read client details direct from Database $query="SELECT firstname FROM tblclients WHERE id='" .$_SESSION['uid'] . "'"; $result = mysql_query($query) or die(mysql_error()); if($line = mysql_fetch_array($result, MYSQL_ASSOC)) { //Load it in php variable $clientsdetails['firstname']=$line['firstname']; } //Load it in Smarty Variable $smartyvalues["clientsdetails"] = $clientsdetails; ?> if you're using the same file to output the variables: <?php echo $clientsdetails['firstname'] ?> if you're using TPL file <p> First Name: {$clientsdetails.firstname} </p> Hope it was helpful 0 Quote Link to comment Share on other sites More sharing options...
sitewes Posted August 3, 2009 Author Share Posted August 3, 2009 Hello, Thanks for a quick response. I will give this code a try and let you know how it went. Thanks! 0 Quote Link to comment Share on other sites More sharing options...
sitewes Posted August 3, 2009 Author Share Posted August 3, 2009 Hello.. That line of code did not work at all.. It kept crashing my site where it the php loaded, never got an error, using Firefox.. But, I did play around with the code some and finally got it to work. This is what I got. <?php $query="SELECT firstname FROM tblclients WHERE id='" .$_SESSION['uid'] . "'"; $result = mysql_query($query); while ($data = mysql_fetch_array($result)) { $firstname = $data["firstname"]; } ?> <?php if ($_SESSION['uid']) { echo("<div class='grid_9 clientarea'>Welcome back <strong>"); echo("$firstname"); echo("</strong>!</div>"); } else { echo("<div class='grid_9 clientarea'>Welcome Guest! Please <a href='#TB_inline?height=125&width=400&inlineId=Thickbox-ClientLogin' class='thickbox' title='Client Area Login'>Login</a> or <a href='account/register.php'>Register</a></div>"); } ?> Thanks for getting me on the right path though. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.