meaton Posted June 16, 2012 Share Posted June 16, 2012 Hello, What I would like to do is show the WHMCS client login form on my websites main page, and that code is shown in the WHMCS admin integration code page. However, if an existing client is already logged in I would like it to reflect that on my websites main page. Example: Welcome back, Bob! [Edit Profile] - [Logout] I did a search on the forums, but I wasn't able to find any info on how to accomplish this, any help would be appreciated! Regards! 0 Quote Link to comment Share on other sites More sharing options...
ipgeek-lg Posted June 17, 2012 Share Posted June 17, 2012 Is your website main page served from the WHMCS install directory? As in my site (http://ipgeek.co.uk) the whmcs install is the / directory. This would make it a lot easier however not impossible if not. 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted June 17, 2012 Share Posted June 17, 2012 Are you using WHMCS as your main page? If not, are they on the same subdomain? 0 Quote Link to comment Share on other sites More sharing options...
meaton Posted June 17, 2012 Author Share Posted June 17, 2012 Are you using WHMCS as your main page? If not, are they on the same subdomain? No I am not using WHMCS as my website, and my site and WHMCS do not run on the same subdomain. Website is on http://www.* and WHMCS is on secure.* 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted June 17, 2012 Share Posted June 17, 2012 sessions are typically subdomain specific, so you arent going to be able to check the session vars on http://www.* to determine if the user is logged in or not. 0 Quote Link to comment Share on other sites More sharing options...
meaton Posted June 17, 2012 Author Share Posted June 17, 2012 Alright, thanks! So, lets say I move WHMCS from it's own subdomain to a sub-folder in http://www.* this would be possible? 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted June 17, 2012 Share Posted June 17, 2012 Alright, thanks! So, lets say I move WHMCS from it's own subdomain to a sub-folder in http://www.* this would be possible? Yup. Then the session would be valid for both URLs. You could check for the existence of $_SESSION['uid'] to see if they're logged in or not. You'd likely have to query the database to get their name, though. Thats not stored in the session. 0 Quote Link to comment Share on other sites More sharing options...
bear Posted June 17, 2012 Share Posted June 17, 2012 We use this on the main site pages, by making a php file in the WHMCS install directory, then calling it into the pages we need using php. IE: include('/path/YOURWHMCS/file.php'); The code (change the obvious): <?php include("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'><span class='loginwelcome'>".$_LANG['welcomeback'].', '.$row['firstname'].': | <a href="/YOURWHMCS/clientarea.php">'.$_LANG['clientareatitle'].'</a> | <a href="/YOURWHMCS/logout.php">'.$_LANG['logouttitle'].'</a></span></p>'; } else{ echo '<form action="https://www.YOURSITE.com/YOURWHMCS/dologin.php" method="post" name="loginform" class="header">Client Login: <input name="username" type="text" class="login" id="username" value="username" size="15""> <input name="password" type="password" id="password" value="xxxxx" size="15""> <input type="hidden" name="token" value="add-your-token-here" /> <input type="image" src="/images/go.gif" width="25" height="19" align="absmiddle"> </form>'; } ?> If the visitor isn't logged in, it shows a form to do so. If they are, it shows their name and links to the client area and to log out. I use an image to submit, and the install directories and token need editing to reflect your own. Some of the CSS classes are mine, so edit those to suit. 0 Quote Link to comment Share on other sites More sharing options...
meaton Posted June 17, 2012 Author Share Posted June 17, 2012 You're awesome, bear. Works like a charm, thanks for sharing! 0 Quote Link to comment Share on other sites More sharing options...
Heteedgeshy Posted June 17, 2012 Share Posted June 17, 2012 In it something is. Thanks for an explanation, the easier, the better … 0 Quote Link to comment Share on other sites More sharing options...
bear Posted June 17, 2012 Share Posted June 17, 2012 You're awesome, bear. Works like a charm, thanks for sharing! You're welcome. This actually exposed a URL issue I had not noticed when I'd upgraded WHMCS, so it helped me, too. In it something is. Thanks for an explanation, the easier, the better … Not following. Did you need something? 0 Quote Link to comment Share on other sites More sharing options...
Heteedgeshy Posted June 17, 2012 Share Posted June 17, 2012 Do not pay attention! 0 Quote Link to comment Share on other sites More sharing options...
bear Posted June 17, 2012 Share Posted June 17, 2012 Do not pay attention! Then why post? 0 Quote Link to comment Share on other sites More sharing options...
disgruntled Posted June 17, 2012 Share Posted June 17, 2012 (edited) sorry bear but i think your talking to a robot.. the sentences make no sense.. then again i suppose they could just have poor english, i just noticed morocco. PS, thanks for the post, something i am considering integrating into my own website, i have whmcs as a sub-directory, not sub-domain but this should do as i need. i just dont like using .php as the main page so i might just have to use a rewrite. I already have them set for my support area tho so isnt too much to add in a new one, i just prefer .html, i know it means nothing really but its just one of my pet hates. Edited June 17, 2012 by disgruntled 0 Quote Link to comment Share on other sites More sharing options...
bear Posted June 17, 2012 Share Posted June 17, 2012 sorry bear but i think your talking to a robot Yup, wasn't quite sure, so gave the benefit of the doubt. Searching that post title about the theme, however, shows he's a drug spammer. PS, thanks for the post, something i am considering integrating into my own website, i have whmcs as a sub-directory, not sub-domain but this should do as i need. i just dont like using .php as the main page You're welcome. Early on I used to dislike php pages because of the issues in previewing the design and having to set up a local XAMPP install for testing, but I grew to like it. Even if I'm not using PHP right away, I go that way anyhow, to make it easier later. I'd done the htaccess/php handler kludge at first and kept them html, but didn't think that was a good plan moving forward. Too many things can go wrong. 0 Quote Link to comment Share on other sites More sharing options...
samkak Posted December 25, 2012 Share Posted December 25, 2012 /http://i45.tinypic.com/727v5x.jpg I am getting this error. Don't know where I am going wrong. Please help. Thanks 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.