Jump to content

Display Client Info outside of WHMCS folder..


sitewes

Recommended Posts

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!

Link to comment
Share on other sites

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 ;)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated