Sitecenter Posted September 29, 2007 Share Posted September 29, 2007 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 0 Quote Link to comment Share on other sites More sharing options...
Retired Forum Member WHMCS Joe Posted September 29, 2007 Retired Forum Member Share Posted September 29, 2007 Please view this article > http://v3manual.whmcs.com/display.php?id=26 0 Quote Link to comment Share on other sites More sharing options...
Sitecenter Posted September 29, 2007 Author Share Posted September 29, 2007 Thanks Joe, I did search the manual but didn't find that article. 0 Quote Link to comment Share on other sites More sharing options...
Daniel Posted September 30, 2007 Share Posted September 30, 2007 Could this be taken outside of WHMCS and be used on the main website too? 0 Quote Link to comment Share on other sites More sharing options...
Retired Forum Member WHMCS Joe Posted September 30, 2007 Retired Forum Member Share Posted September 30, 2007 To create your own pages to use with WHMCS please view this article http://support.whmcs.com/knowledgebase.php?action=displayarticle&catid=7&id=26 0 Quote Link to comment Share on other sites More sharing options...
Daniel Posted September 30, 2007 Share Posted September 30, 2007 I've tried including that on the page but it seems to stop the rest of the page from loading after that part. Basically, i'm trying to get it to say "Welcome back, Daniel" if logged in, if not then it'll display a link to the client area. 0 Quote Link to comment Share on other sites More sharing options...
Sitecenter Posted September 30, 2007 Author Share Posted September 30, 2007 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 0 Quote Link to comment Share on other sites More sharing options...
Daniel Posted September 30, 2007 Share Posted September 30, 2007 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? 0 Quote Link to comment Share on other sites More sharing options...
Sitecenter Posted September 30, 2007 Author Share Posted September 30, 2007 Sorry, not sure mate. Haven't got that far yet as we wont have a proper front end initially as it'll be manual orders from us or from my other web businesses and they'll just use a link to order from the back end. 0 Quote Link to comment Share on other sites More sharing options...
WHMCS CEO Matt Posted September 30, 2007 WHMCS CEO Share Posted September 30, 2007 Daniel, That won't work. You are trying to use Smarty template code in a PHP file and not a template! I'm pretty sure I included the PHP code to be able to tell if a user was "logged in" in the sample page code. Matt 0 Quote Link to comment Share on other sites More sharing options...
Daniel Posted October 1, 2007 Share Posted October 1, 2007 Thanks Matt - I'm not sure what you mean by the sample page though? Dan 0 Quote Link to comment Share on other sites More sharing options...
Sitecenter Posted October 1, 2007 Author Share Posted October 1, 2007 Dan, I think he means the one Joe mentioned above - http://support.whmcs.com/knowledgebase.php?action=displayarticle&catid=7&id=26 0 Quote Link to comment Share on other sites More sharing options...
Daniel Posted October 1, 2007 Share Posted October 1, 2007 Using that code, even in its default state, with no message for logged in users, causes my page to load blank. I've tried it as an include and pasting it directly, still nothing. 0 Quote Link to comment Share on other sites More sharing options...
Sitecenter Posted October 1, 2007 Author Share Posted October 1, 2007 I'm no expert but the code that is supplied in that help page is designed to be used on the pages within the Smarty template system I believe. I'm afraid my knowledge doesnt extend far enough (just yet!) to help with what you want to do. 0 Quote Link to comment Share on other sites More sharing options...
Daniel Posted October 3, 2007 Share Posted October 3, 2007 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? 0 Quote Link to comment Share on other sites More sharing options...
Sitecenter Posted October 3, 2007 Author Share Posted October 3, 2007 Would you not use a standard php query to check the name that's in the database for the given email address? 0 Quote Link to comment Share on other sites More sharing options...
Daniel Posted October 3, 2007 Share Posted October 3, 2007 Probably, I wondered if there was a way of including the smarty template code by pulling in another file from WHMCS. 0 Quote Link to comment Share on other sites More sharing options...
TheIdeaMan Posted February 19, 2008 Share Posted February 19, 2008 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. 0 Quote Link to comment Share on other sites More sharing options...
TheIdeaMan Posted February 19, 2008 Share Posted February 19, 2008 Unless this is it: http://v3manual.whmcs.com/display.php?id=26 0 Quote Link to comment Share on other sites More sharing options...
JasonO Posted February 19, 2008 Share Posted February 19, 2008 Can you not do {debug} to show it inside WHMCS? Just a guess. 0 Quote Link to comment Share on other sites More sharing options...
TheIdeaMan Posted February 19, 2008 Share Posted February 19, 2008 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... 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.