siforek Posted June 10, 2009 Share Posted June 10, 2009 treme[Z];108483']1st part i save as isloggedin.php 2nd part I save as something.php http://seahosting.net/yourside.php But I got a blank page.. Sorry.. Save the first part as isloggedin.php Then change "pathto/whmcs/isloggedin.php" in the second part to the correct path.. 0 Quote Link to comment Share on other sites More sharing options...
e[X]treme[Z] Posted June 11, 2009 Share Posted June 11, 2009 Sorry.. Save the first part as isloggedin.php Then change "pathto/whmcs/isloggedin.php" in the second part to the correct path.. Yes.. that is what i did. I'm using WHMCS4, I don't know if that might help Code in http://seahosting.net/yourside.php <?php include('clients/isloggedin.php'); if ($isloggedin){ echo "logged in to whmcs"; } ?> 0 Quote Link to comment Share on other sites More sharing options...
herpherp Posted June 11, 2009 Share Posted June 11, 2009 treme[Z];108676']rl] <?php include('clients/isloggedin.php'); if ($isloggedin){ echo "logged in to whmcs"; } ?> try <?php include('home/public_html/yourUSERname/clients/isloggedin.php'); if ($isloggedin){ echo "logged in to whmcs"; } ?> And make sure you are logged in when accessing that page (client side) if your not logged in you would obviously get a blank page. 0 Quote Link to comment Share on other sites More sharing options...
e[X]treme[Z] Posted June 11, 2009 Share Posted June 11, 2009 (edited) I got it working and now implemented on my website. Thanks for all the help. BTW: How do I make it welcome back $firstname ? Edited June 11, 2009 by e[X]treme[Z] 0 Quote Link to comment Share on other sites More sharing options...
siforek Posted June 11, 2009 Share Posted June 11, 2009 treme[Z];108778']I got it working and now implemented on my website. Thanks for all the help. BTW: How do I make it welcome back $firstname ? <?php require("dbconnect.php"); if ($_SESSION['uid']) { $isloggedin = 'true'; // off the top of my head I can't recall if the session stores user info other than the ID. So otherwise you'd have to query the database here. Use WHERE id = $_SESSION['uid'] } ?> You can check what session info there is with: <pre> {php}print_r($_SESSION);{/php} </pre> 0 Quote Link to comment Share on other sites More sharing options...
ZaGGi Posted June 29, 2009 Share Posted June 29, 2009 sorry whmcs 4.0 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted July 18, 2009 Share Posted July 18, 2009 So if whcms is installed at subdomain.domain.com, there probably isnt any way to check the auth from http://www.domain.com is there? Because the session is only good for subdomain.domain.com, right? Im trying to figure a way to do it without using a stupid iframe. =/ 0 Quote Link to comment Share on other sites More sharing options...
weblantis Posted October 13, 2010 Share Posted October 13, 2010 Try this: something.php (located in the WHMCS dir <?php require("dbconnect.php"); if ($_SESSION['uid']) { $isloggedin = 'true'; } ?> yoursite.php <?php include('pathto/whmcs/isloggedin.php'); if ($isloggedin){ echo "logged in to whmcs"; } ?> Thanks for this. This actually works Based on this I have made improvements to your code to make it more fuller and css tag friendly. I also moved the IF conditional statement into the whmcs folder. Anyway here it is: something.php (located in the WHMCS dir <?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="/whmcs/clientarea.php"><strong>'.$_LANG['clientareanavdetails'].'</strong></a> | <a href="/whmcs/logout.php"><strong>'.$_LANG['logouttitle'].'</strong></a></p>'; } else{ echo "<p id='login'>".$_LANG['please'].' <a href="/whmcs/clientarea.php" title="Login"><bold>'.$_LANG['loginbutton'].'</bold></a> '.$_LANG['or'].' <a href="/whmcs/register.php" title="Register"><bold>'.$_LANG['clientregistertitle'].'</bold></a></p>'; } ?> yoursite.php (any php file outside whmcs folder) <?php include('pathto/whmcs/something.php'); ?> 0 Quote Link to comment Share on other sites More sharing options...
okomba Posted October 14, 2010 Share Posted October 14, 2010 Does this trick still work? I am using whmcs_v431 and $_SESSION['uid'] is always empty even when I am logged in. Thanks. Mugoma, hostyetu.com 0 Quote Link to comment Share on other sites More sharing options...
weblantis Posted October 14, 2010 Share Posted October 14, 2010 Does this trick still work? I am using whmcs_v431 and $_SESSION['uid'] is always empty even when I am logged in. Thanks. Mugoma, hostyetu.com I am using Version 4.3.1 and it is working fine. Are you using relative or absolute paths when you call the login_status.php using the php include method? I discovered that this solution only works if you use relative paths instead of absolute paths. 0 Quote Link to comment Share on other sites More sharing options...
okomba Posted October 14, 2010 Share Posted October 14, 2010 Hi. I have also tried relative path but still $_SESSION['uid'] doesn't have any values. But I could be doing it wrongly. This is what I have done: 1. I have service/isloggedin.php with the content: <?php require("dbconnect.php"); //echo $_SESSION['uid']." - _SESSION['uid']"; if ($_SESSION['uid']) { $isloggedin = 'true'; } ?> 2. Then in my header.php I have: <?php include('service/isloggedin.php'); //echo $isloggedin." - isloggedin"; if ( $isloggedin ) { ?> Welcome, <?php echo $clientsdetails['firstname'] } ?> Both echo $_SESSION['uid'] and echo $isloggedin shows nothing even when logged in. What could I be doing wrong? Please assist. Thanks. Mugoma. 0 Quote Link to comment Share on other sites More sharing options...
weblantis Posted October 14, 2010 Share Posted October 14, 2010 Try copying and pasting my code exactly as shown (but update the paths and filenames where necessary). I think your problem might be caused by having the IF statement on the wrong side. All IF statements should be in the isloggedin.php file. There should be no IF statements in the header.php file. 0 Quote Link to comment Share on other sites More sharing options...
bear Posted October 14, 2010 Share Posted October 14, 2010 This works fine in mine, but blows up the rest of the page as I also have announcements being displayed on the same page. The two requires for the dbconnect file are to blame (one for each include), but if I kill either call that include fails. Using "mysql_close();" does nothing, as I believe the connection is persistent. Love to use this, but unless I can puzzle out how to get them both to play nice, I can't. Suggestions welcome. [EDIT] Got it. Removed the dbconnect call from the included announcements file, and it uses the connection already established earlier in the page for the login switch. 0 Quote Link to comment Share on other sites More sharing options...
okomba Posted October 14, 2010 Share Posted October 14, 2010 Hi. Most likely there could be a problem with my setup but I haven't managed to figure out source of problem. E.g. in service/isloggedin.php if I just put: <?php require("dbconnect.php"); echo $_SESSION['uid']." - _SESSION['uid']"; ?> The $_SESSION['uid'] shows nothing, whether I am logged in or not. Should't it give 'true' or 'false'? So obviously the complete version will have $isloggedin not set. Do I need to put session_start(); somewhere to get a value from $_SESSION['uid']? Since most people have reported the method working for them I will assume my setup could be the issue. I will be very grateful for any clue. Thanks. Mugoma. Try copying and pasting my code exactly as shown (but update the paths and filenames where necessary). I think your problem might be caused by having the IF statement on the wrong side. All IF statements should be in the isloggedin.php file. There should be no IF statements in the header.php file. 0 Quote Link to comment Share on other sites More sharing options...
othellotech Posted October 15, 2010 Share Posted October 15, 2010 The two requires change them to requires_once 0 Quote Link to comment Share on other sites More sharing options...
bear Posted October 15, 2010 Share Posted October 15, 2010 Nice one, thanks. It's apparently require_once though. 0 Quote Link to comment Share on other sites More sharing options...
okomba Posted October 15, 2010 Share Posted October 15, 2010 Hi. Just in case this could be a hint. When I do print_r ($_SESSION); I get: Array ( [adminloggedinstatus] => true [adminid] => 1 [adminpw] => fe591de2067a827ffd2da33f59e80697 ) 0 Quote Link to comment Share on other sites More sharing options...
okomba Posted October 19, 2010 Share Posted October 19, 2010 Hello. I finally figured it out. It was a very stupid omission. The reason for $_SESSION['uid'] being empty was that I was accessing WHMCS login via www. while the main website I was accessing without www. That made all the difference! Could not figure it out till a few hours ago. Thanks WHMCS Support for that! Mugoma. Hi. Just in case this could be a hint. When I do print_r ($_SESSION); I get: Array ( [adminloggedinstatus] => true [adminid] => 1 [adminpw] => fe591de2067a827ffd2da33f59e80697 ) 0 Quote Link to comment Share on other sites More sharing options...
Kichas Posted October 20, 2010 Share Posted October 20, 2010 is there anyway of being able to login to whmcs from my website without being redirected to whmcs? 0 Quote Link to comment Share on other sites More sharing options...
bacterie Posted October 20, 2010 Share Posted October 20, 2010 (edited) Hello, I'm trying to login into whmc from joomla and i need to know it the user has been logged in in order to remove the login form if the user is logged in. For this I followed the instructions you guys kindly shared. I have in /home/website/public_html/client/isin.php (the WHMCS install folder) <?php require("dbconnect.php"); if ($_SESSION['uid']) { $isloggedin = 'true'; } ?> In the /home/website/public_html/modules/mod_login/tmpl/default.php (the joomla login module) <?php include("home/atom-hosting/public_html/client/isin.php"); if ($isloggedin == FALSE){ ?> <form method="post" action="https://website.com/client/dologin.php"> <input id="modlgn_username" type="text" name="username" value="email" onclick="this.value=''" class="username" /> <input id="modlgn_passwd" type="password" name="password" value="password" onclick="this.value=''"class="password" /> <input type="submit" name="Submit" class="submit" value="Login" /> <div style="border:#000000; padding:0 6px 0 0; float:right;"> <a href="https://website.com/client/pwreset.php">Forgot your password?</a></div> <input type="hidden" name="task" value="ulogin" /> </form> <?php } ?> I get an error that says the file can't be opened Warning: require_once(home/website/public_html/client/isin.php) [function.require-once]: failed to open stream: No such file or directory in /home/website/public_html/client/default.php on line 5 Fatal error: require_once() [function.require]: Failed opening required 'home/website/public_html/client/isin.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/website/public_html/client/default.php on line 5 The path is correct, the file has proper permissions , I don't know what else to do. Thanks Edited October 20, 2010 by bacterie 0 Quote Link to comment Share on other sites More sharing options...
jeremyhaber Posted October 20, 2010 Share Posted October 20, 2010 Does the home directory not need a pre-pended slash? include("home/atom-hosting/public_html/client/isin.php"); Should be: include("/home/atom-hosting/public_html/client/isin.php"); Also on that note your line of code that includes the database should be an absolute path as I believe it will look from the directory you are calling the include from (if its not calling from the same directory). require("dbconnect.php"); As well "session_start();" may be required in the isin.php file unless you have php setup to do this automatically. And also this is a small issue but assigning a variable 'true' is setting the variable as a string and not the value of true. Remove the quotes and you can use less memory as well as have 2 less characters to type. 0 Quote Link to comment Share on other sites More sharing options...
bacterie Posted October 20, 2010 Share Posted October 20, 2010 Does the home directory not need a pre-pended slash?include("home/atom-hosting/public_html/client/isin.php"); Should be: include("/home/atom-hosting/public_html/client/isin.php"); Also on that note your line of code that includes the database should be an absolute path as I believe it will look from the directory you are calling the include from (if its not calling from the same directory). require("dbconnect.php"); As well "session_start();" may be required in the isin.php file unless you have php setup to do this automatically. And also this is a small issue but assigning a variable 'true' is setting the variable as a string and not the value of true. Remove the quotes and you can use less memory as well as have 2 less characters to type. Hello, If I write the include like this include("/home/atom-hosting/public_html/client/isin.php"); i get a message that says: Down for Maintenance An upgrade is currently in progress... Please come back soon... The isin.php is in the same directory as the dbconnect.php file. Thanks 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted November 29, 2010 Share Posted November 29, 2010 Hello, If I write the include like this include("/home/atom-hosting/public_html/client/isin.php"); i get a message that says: Down for Maintenance An upgrade is currently in progress... Please come back soon... The isin.php is in the same directory as the dbconnect.php file. Thanks yeah, im having the same issue with the "Down for Maintenance An upgrade is currently in progress... Please come back soon..." error. I know I must be having a brain fart and missing something simple. 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.