Solarpitch Posted June 26, 2007 Share Posted June 26, 2007 I have the following code that prints a link based on the value of a session... It seems to output a string of the code rather than the link it should... freaky! <?php if (isset($_SESSION['valid_user'])) { echo '<a href="member_logout.php">Logout</a>'; } else { echo '<a href="member_login.php">Login</a>'; } ?> Actual Output: Logout'; } else { echo 'Login'; } ?> Quote Link to comment Share on other sites More sharing options...
.Stealth Posted June 26, 2007 Share Posted June 26, 2007 i think it must be your quotes, its the only thing that dosent look right. try: <?php if (isset($_SESSION['valid_user'])) { echo "<a href=\"member_logout.php\">Logout</a>"; } else { echo "<a href=\"member_login.php\">Login</a>"; } ?> Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted June 26, 2007 Author Share Posted June 26, 2007 Yeah, I know its the quotes but I dont know whats wrong... your code prints as Logout"; } else { echo "Login"; } ?> Quote Link to comment Share on other sites More sharing options...
Dragen Posted June 26, 2007 Share Posted June 26, 2007 It's probably due to some miscoding somewhere, such as a missed out bracket or semi-colon etc.. unless it's just how you've formatted it. This works fine for me: <?php if(isset($_SESSION['valid_user'])){ echo '<a href="member_logout.php">Logout</a>'; }else{ echo '<a href="member_login.php">Login</a>'; } ?> could you post some more code around that area? Quote Link to comment Share on other sites More sharing options...
trq Posted June 26, 2007 Share Posted June 26, 2007 Something appears to be wrong with your php install. The code is fine. What does the html source look like? eg; right click -> view source. Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted June 26, 2007 Author Share Posted June 26, 2007 Not really because I am sticking it into the "overall_header.tpl" page in phpbb forum. I am modifying the logon links. The code works fine on other page, just not this one! Quote Link to comment Share on other sites More sharing options...
trq Posted June 26, 2007 Share Posted June 26, 2007 Chances are there may be an error in your overall_header.tpl then. Poorly formatted html can sometimes lead to wierd errors. Quote Link to comment Share on other sites More sharing options...
Dragen Posted June 26, 2007 Share Posted June 26, 2007 if you're just trying to display a login/logout link why don't you use the built in switches for phpbb? <a href="{U_LOGIN_LOGOUT}" class="mainmenu">{L_LOGIN_LOGOUT}</a> That will print out the correct link whether you're logged in or logged out in phpbb forums Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted June 26, 2007 Author Share Posted June 26, 2007 Yeah, But I need to change the pages each of the links call. I want it to redirect to a page on my own site when logging out and not the standard phpbb one. Is there a way I can do that . . modify the switches themselves? that would be excellent! Quote Link to comment Share on other sites More sharing options...
Dragen Posted June 26, 2007 Share Posted June 26, 2007 yeah. I think this is how to do it: open: includes/page_header.php find: // // Generate logged in/logged out status // if ( $userdata['session_logged_in'] ) { $u_login_logout = 'login.'.$phpEx.'?logout=true&sid=' . $userdata['session_id']; $l_login_logout = $lang['Logout'] . ' <br />[ ' . $userdata['username'] . ' ]'; } else { $u_login_logout = 'login.'.$phpEx; $l_login_logout = $lang['Login']; } change the $u_login_logout parts to link to your pages. eg: // // Generate logged in/logged out status // if ( $userdata['session_logged_in'] ) { $u_login_logout = 'http://www.mydomain.com/logout.'.$phpEx; $l_login_logout = $lang['Logout'] . ' <br />[ ' . $userdata['username'] . ' ]'; } else { $u_login_logout = 'http://www.mydomain.com/login.'.$phpEx; $l_login_logout = $lang['Login']; } note that the $phpEx variable adds php to the end of the filename. Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted June 26, 2007 Author Share Posted June 26, 2007 Yeah I think this is it... it doesnt work yet but I'll play around with it for a bit and it should be fine! Thanks for that! 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.