craigrg Posted January 8, 2010 Share Posted January 8, 2010 Hi people I am currently working on intagrating WHMCS with my website. What i am wanting to do is use the logging code that is used on the portal template on the top right which is located http://www.mydomain.com/client'>http://www.mydomain.com/client I would like to use the code in the root directory http://www.mydomain.com I know that there is the Integration Code in the admin panel but that does not give the welcome message when a user logs in. <div id="welcome_box">{if $loggedin}{$LANG.welcomeback}, <strong>{$clientsdetails.firstname}</strong> <img src="templates/{$template}/images/icons/details.gif" alt="{$LANG.clientareanavdetails}" width="16" height="16" border="0" class="absmiddle" /> <a href="clientarea.php?action=details" title="{$LANG.clientareanavdetails}"><strong>{$LANG.clientareanavdetails}</strong></a> <img src="templates/{$template}/images/icons/logout.gif" alt="{$LANG.logouttitle}" width="16" height="16" border="0" class="absmiddle" /> <a href="logout.php" title="Logout"><strong>{$LANG.logouttitle}</strong></a>{else}{$LANG.please} <a href="clientarea.php" title="{$LANG.loginbutton}"><strong>{$LANG.loginbutton}</strong></a> {$LANG.or} <a href="register.php" title="{$LANG.clientregistertitle}"><strong>{$LANG.clientregistertitle}</strong></a>{/if}</div> 0 Quote Link to comment Share on other sites More sharing options...
m00 Posted January 8, 2010 Share Posted January 8, 2010 (edited) Not the most beautiful solution, but it will do the job: <?php require("client/dbconnect.php"); // Give in the path to the dbconnect.php in the WHMCS root. if($_SESSION['uid']) { $result = mysql_query("SELECT firstname FROM tblclients WHERE id='".$_SESSION['uid']."' LIMIT 1;"); while($row = mysql_fetch_array($result)) echo $_LANG['welcomeback'].", ".$row['firstname']."<br /><a href=\"clientarea.php?action=details\"><strong>".$_LANG['clientareanavdetails']."</a> <a href=\"logout.php\"><strong>".$_LANG['logouttitle']."</strong></a>"; } else echo $_LANG['please']." <a href=\"clientarea.php\" title=\"Login\"><strong>".$_LANG['loginbutton']."</strong></a> ".$_LANG['or']." <a href=\"register.php\" title=\"Register\"><strong>".$_LANG['clientregistertitle']."</strong></a>"; ?> Edited January 8, 2010 by m00 0 Quote Link to comment Share on other sites More sharing options...
craigrg Posted January 8, 2010 Author Share Posted January 8, 2010 Thanks for the reply. Will have a look now. 0 Quote Link to comment Share on other sites More sharing options...
craigrg Posted January 8, 2010 Author Share Posted January 8, 2010 Will this code work in a html page? 0 Quote Link to comment Share on other sites More sharing options...
m00 Posted January 8, 2010 Share Posted January 8, 2010 Will this code work in a html page? No, only in a PHP page. 0 Quote Link to comment Share on other sites More sharing options...
craigrg Posted January 8, 2010 Author Share Posted January 8, 2010 do you know the code for a html page or would it be just as easy to change the page to .php? 0 Quote Link to comment Share on other sites More sharing options...
m00 Posted January 8, 2010 Share Posted January 8, 2010 HTML is a static code, PHP is dynamic. You can't run PHP code inside a HTML file. What you can do is the following. Make a file in your WHMCS directory (/client/) called status.php and put in the following code: <?php require("dbconnect.php"); if($_SESSION['uid']) { $result = mysql_query("SELECT firstname FROM tblclients WHERE id='".$_SESSION['uid']."' LIMIT 1;"); while($row = mysql_fetch_array($result)) echo "document.write('".$_LANG['welcomeback'].", ".$row['firstname']." | <a href=\"clientarea.php?action=details\"><strong>".$_LANG['clientareanavdetails']."</a> <a href=\"logout.php\"><strong>".$_LANG['logouttitle']."</strong></a>');"; } else echo "document.write('".$_LANG['please']." <a href=\"clientarea.php\" title=\"Login\"><strong>".$_LANG['loginbutton']."</strong></a> ".$_LANG['or']." <a href=\"register.php\" title=\"Register\"><strong>".$_LANG['clientregistertitle']."</strong></a>');"; ?> Put the following code in your HTML page: <script type="text/javascript" src="client/status.php"></script> It will show you the login status using Javascript, which is possible in HTML. 0 Quote Link to comment Share on other sites More sharing options...
Waqas Saeed Posted July 9, 2021 Share Posted July 9, 2021 I'm using the 3rd party payment gateway has a callback file, however the callback file is not too much protected due to IPN response from the gateway, since I wanted to know if I can make the $CUSTOM_SESSION['invoice_id'] in view invoice as client page , then check the invoice id at callback file. 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted July 9, 2021 Share Posted July 9, 2021 As I mentioned in another thread, the callback should not know, care, touch, or otherwise access the client's account beyond the invoice as only the gateway should be calling it. 1 Quote Link to comment Share on other sites More sharing options...
Nanox Flow Posted July 10, 2021 Share Posted July 10, 2021 (edited) Hi I have tried in WHMCS 8.1 is not working, on external page im not getting the status <script type="text/javascript" src="client/status.php"></script> Edited July 10, 2021 by Nanox Flow 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted July 10, 2021 Share Posted July 10, 2021 (edited) The above code wont work because mysql_query was removed in PHP 7 and really using WHMCS internal classes and making WHMCS do the heavy lifting for database access is the preferred way, at least IMO. As such, here you go in a untested rewrite: <?php require("../init.php"); use WHMCS\User\Client; /* * @Author steven99 * Get status of current status of client and welcome them back or have them login . * NOTE: This will only work within WHMCS and not an external page as it requires * the same PHP session to be used */ global $_LANG; if (isset($_SESSION['UID']) and is_numeric($_SESSION['UID'])) { $Client = Client::find($_SESSION['UID']); if ($Client) {?> <?=$_LANG['welcomeback']?> <?=$Client->firstname?> <a href="clientarea.php?action=details"><strong><?=$_LANG['clientareanavdetails']?></a> <a href="logout.php"><strong><?=$_LANG['logouttitle']?></strong></a> <?php } } else {?> <?=$_LANG['please']?> <a href="clientarea.php" title="Login"><strong><?=$_LANG['loginbutton']?></strong></a><?=$_LANG['or']?> <a href="register.php" title="Register"><strong><?=$_LANG['clientregistertitle']?></strong></a> <?php } Edited July 10, 2021 by steven99 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.