sequencehost Posted January 10, 2012 Share Posted January 10, 2012 Hello, I'm using the following code to display the top bar (logged-in navigation) on non-WHMCS pages. It works really well but I'm struggling to add the else statement to show content when not logged in. If someone could help with this I'd be greatly appreciative: <?php require("/home/username/public_html/folder/dbconnect.php"); if ($_SESSION['uid']) { $query="SELECT * FROM tblclients WHERE id='" .sanitize($_SESSION['uid']). "'"; $result = mysql_query($query) or die(mysql_error()); if($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $clientsdetails['firstname']=$row['firstname']; $clientsdetails['lastname']=$row['lastname']; $clientsdetails['email']=$row['email']; } echo ' <div class="topbar"> <div class="fill"> <ul> <li><a href="/clients/clientarea.php">Home</a></li> </ul> <ul> <li class="menu"> <a href="#" class="menu">Services</a> <ul class="menu-dropdown"> <li><a href="/clients/clientarea.php?action=products">My Services</a></li> <li class="divider"></li> <li><a href="/clients/cart.php">Order New Services</a></li> <li><a href="/clients/cart.php?gid=addons">View Available Addons</a></li> </ul> </li> </ul> <ul> <li class="menu"> <a href="#" class="menu">Domains</a> <ul class="menu-dropdown"> <li><a href="/clients/clientarea.php?action=domains">My Domains</a></li> <li class="divider"></li> <li><a href="/clients/cart.php?gid=renewals">Renew Domains</a></li> <li><a href="/clients/cart.php?a=add&domain=register">Register a New Domain</a></li> <li><a href="/clients/cart.php?a=add&domain=transfer">Transfer Domains to Us</a></li> <li class="divider"></li> <li><a href="/clients/domainchecker.php">Whois Lookup</a></li> </ul> </li> </ul> <ul> <li class="menu"> <a href="#" class="menu">Billing</a> <ul class="menu-dropdown"> <li><a href="/clients/clientarea.php?action=invoices">My Invoices</a></li> <li><a href="/clients/clientarea.php?action=quotes">My Quotes</a></li> </ul> </li> </ul> <ul> <li class="menu"> <a href="#" class="menu">Support</a> <ul class="menu-dropdown"> <li><a href="/clients/supporttickets.php">Tickets</a></li> <li><a href="http://www.zomex.com/lab">Knowledgebase</a></li> <li><a href="/clients/downloads.php">Downloads</a></li> <li><a href="/clients/serverstatus.php">Network Status</a></li> </ul> </li> </ul> <ul> <li><a href="/clients/submitticket.php">Open Ticket</a></li> </ul> <ul> <li><a href="/clients/affiliates.php">Affiliates</a></li> </ul> <ul class="nav secondary-nav"> <li class="menu"> <a href="#" class="menu">Hello, '.($row['firstname']).'!</a> <ul class="menu-dropdown"> <li><a href="/clients/clientarea.php?action=details">Edit Account Details</a></li> <li><a href="/clients/clientarea.php?action=contacts">Contacts/Sub-Accounts</a></li> <li><a href="/clients/clientarea.php?action=addfunds">Add Funds</a></li> <li><a href="/clients/clientarea.php?action=emails">Emails Sent</a></li> <li><a href="/clients/clientarea.php?action=changepw">Change Password</a></li> <li class="divider"></li> <li><a href="/clients/logout.php">Logout</a></li> </ul> </li> </ul> </div> </div> '; } ?> PS: If someone can confirm it's secure anyone reading this is free to use it. 0 Quote Link to comment Share on other sites More sharing options...
bear Posted January 11, 2012 Share Posted January 11, 2012 Right at the bottom: </div> </div> '; }else{ echo 'other stuff here'; } ?> You have some unescaped single quotes in there, too (might not be all of them): <li class="menu"> <a href="#" class="menu">Hello, '.($row['firstname']).'!</a> 0 Quote Link to comment Share on other sites More sharing options...
Sitepearl Posted January 11, 2012 Share Posted January 11, 2012 Why not take advantage of smarty caching and do this through a .tpl file? Then it's simple: {if $logged_in}Woo{else}Hoo{/if} 0 Quote Link to comment Share on other sites More sharing options...
mylove4life Posted January 11, 2012 Share Posted January 11, 2012 Can't on a non-whmcs page Why not take advantage of smarty caching and do this through a .tpl file? Then it's simple: 0 Quote Link to comment Share on other sites More sharing options...
mylove4life Posted January 11, 2012 Share Posted January 11, 2012 I myself just make all the pages load in whmcs and you are done... 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.