Jump to content

Showing the users logged in


Sitecenter

Recommended Posts

On our site we have a login form at the top of the page which the client can use to log in to the clients area.

 

It now uses the standard code as given in the manual but what I would like to do is check on each page and if the user is logged in, do not show the form but instead a message such as "Welcome back (firstname). You have x invoices outstanding."

 

Possible and if so, can anyone guide me in the right direction? I realise it will be some sort of if statement but it's knowing what variable i'm checking for for the logged in user etc.

 

 

Thanks

 

Paul

Link to comment
Share on other sites

Daniel,

 

I've got it working very, very easily and have started moving links around in the client area. The only thing left to do now is to make every client page require the user to be logged in.

 

Check this out:

 

{if $loggedin}



Welcome back {$clientsdetails.firstname}

{else}

           <form class="login" action="http://yourdomain.com/clients/dologin.php?goto=clientarea" method="post" title="Client Login Form">
               <fieldset>
                   <legend>Client Login</legend>
                   <label for="username">User Name</label><input type="text" class="grad" name="username" value="email address" />
                   <label for="password">Password</label><input type="password" class="grad" name="password" value="password" />
                   <input type="submit" class="miniSubmit" name="submit"/>
                   [url=""]forgotten password?[/url]
               </fieldset>
           </form>

{/if}

 

Hope this helps

Link to comment
Share on other sites

Thanks,

 

In that case, that means this code should work for pages outside of WHMCS.

 

<?php

require("dbconnect.php");
require("includes/functions.php");

$pagetitle = $_LANG['clientareatitle'];
$pageicon = "images/support/clientarea.gif";
$breadcrumbnav=''.$_LANG['globalsystemname'].'';

require("init.php");

{if $loggedin}



Welcome back {$clientsdetails.firstname}

  {else}

           <form class="login" action="http://yourdomain.com/clients/dologin.php?goto=clientarea" method="post" title="Client Login Form">
               <fieldset>
                   <legend>Client Login</legend>
                   <label for="username">User Name</label><input type="text" class="grad" name="username" value="email address" />
                   <label for="password">Password</label><input type="password" class="grad" name="password" value="password" />
                   <input type="submit" class="miniSubmit" name="submit"/>
                   [url=""]forgotten password?[/url]
               </fieldset>
           </form>

  {/if}

# Define the template filename to be used without the .tpl extension
$templatefile = "homepage";

/*
To assign variables in Smarty use the following syntax.
$smarty->assign('variablename', $value);
This can then be used as {$variablename} in the template
*/

include("display.php");

?> 

 

 

As long as the include paths are changed, it should work, right?

Link to comment
Share on other sites

I've got it partly working.

 

<?php

require("../order/dbconnect.php");
require("../order/includes/functions.php");

$pagetitle = $_LANG['clientareatitle'];
$pageicon = "images/support/clientarea.gif";
$breadcrumbnav=''.$_LANG['globalsystemname'].'';

require("../order/init.php");

if ($_SESSION['loggedinstatus']=="true") {
echo ("Welcome Back"); 
} else {
echo ("Billing Login | Control Panel Login"); }

# Define the template filename to be used without the .tpl extension
$templatefile = "homepage";

/*
To assign variables in Smarty use the following syntax.
$smarty->assign('variablename', $value);
This can then be used as {$variablename} in the template
*/

include("../order/display.php");

?> 

 

The only thing that I can't get working is the clients name. I've been trying to pull the first name from the database but seeing as its outside of WHMCS I can't use the smarty code.

Any ideas?

Link to comment
Share on other sites

  • 4 months later...

I think what you're looking for is the $clientsdetails variable. It's an array and has the clients ID, first name, and last name in it.

 

Matt, do you have a list of variables like this one that are available to custom client pages like the one mentioned in this thread?

 

A list of those would be very helpful.

 

Thanks for all you do, Matt.

Link to comment
Share on other sites

That'll only show you what's made it to the Smarty template. Which, without manually assigning them (per the comment in the sample code), you'd not have much to work with.

 

What I'm working with now is using the user id from the $clientdetails variable to do a manual sql query to pull up the accounts list (what I need for my custom page). It's not ideal, but there are db_host, db_username, db_password, and db_name variables available so you can avoid declaring those again.

 

I'm on to getting the smarty file to display now...

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