Jump to content

Displaying whether a user is logged in or not on a page outside of WHMCS.


edwardtate

Recommended Posts

Hello,

 

I've been digging through the forums for a few hours now, and with no luck. I saw a lot of similar topics, where the solutions worked for others, but they aren't working for me.

 

Basically, I've built my websites homepage and some other pages outside of the WHMCS installation folder, and I'd like to be able to display on my homepage whether a user is already logged on, and if so display a welcome message and have a link to the client area, and if not, a welcome message to the guest and a link to the login page.

 

I know there are a lot of forum posts about this, but they are outdated and none of the methods worked for me. I'm using WHMCS version 5.1.3.

 

I know it's a pain, and I feel slack for asking, but I've been stumped for hours upon hours, if someone could please show me some sample code that works with later versions, that'd be absolutely fantastic.

 

Thanks sincerely in advance.

 

~ Eddie.

Link to comment
Share on other sites

Firstly, you need to create a file, name it anything you want, as long as it's not overwriting a system file, containing the following:

 

<?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 "<p id='login'>".$_LANG['welcomeback'].', '.$row['firstname'].' <a href="/clients/clientarea.php"><strong>'.$_LANG['clientareanavdetails'].'</strong></a> <a href="/clients/logout.php"><strong>'.$_LANG['logouttitle'].'</strong></a></p>';
}
else{
   echo "<p id='login'>".$_LANG['please'].' <a href="/clients/clientarea.php" title="Login"><bold>'.$_LANG['loginbutton'].'</bold></a> '.$_LANG['or'].' <a href="/clients/register.php" title="Register"><bold>'.$_LANG['clientregistertitle'].'</bold></a></p>';
}
?>

 

And place it in the WHMCS directory. Then, on whatever page you want, add this line where you want the output to be displayed:

 

<?php include('your/WHMCS/directory/fileyounamed.php'); ?>

 

That will check to see if a user is logged in or not, and displays the appropriate greeting. You can change the text displayed by editing WHMCS/lang/which-ever-language-file-you-are-using.php, and doing a quicksearch in the file for example: "clientareanavdetails".

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