Jump to content

Possible to show "Welcome back [name]" otherwise show login form...


meaton

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 by disgruntled
Link to comment
Share on other sites

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. ;)

Link to comment
Share on other sites

  • 6 months later...

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