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'; } ?> Link to comment https://forums.phpfreaks.com/topic/57279-just-a-little-output-question/ 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>"; } ?> Link to comment https://forums.phpfreaks.com/topic/57279-just-a-little-output-question/#findComment-283113 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"; } ?> Link to comment https://forums.phpfreaks.com/topic/57279-just-a-little-output-question/#findComment-283117 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? Link to comment https://forums.phpfreaks.com/topic/57279-just-a-little-output-question/#findComment-283120 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. Link to comment https://forums.phpfreaks.com/topic/57279-just-a-little-output-question/#findComment-283121 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! Link to comment https://forums.phpfreaks.com/topic/57279-just-a-little-output-question/#findComment-283128 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. Link to comment https://forums.phpfreaks.com/topic/57279-just-a-little-output-question/#findComment-283131 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 Link to comment https://forums.phpfreaks.com/topic/57279-just-a-little-output-question/#findComment-283132 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! Link to comment https://forums.phpfreaks.com/topic/57279-just-a-little-output-question/#findComment-283136 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. Link to comment https://forums.phpfreaks.com/topic/57279-just-a-little-output-question/#findComment-283150 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! Link to comment https://forums.phpfreaks.com/topic/57279-just-a-little-output-question/#findComment-283160 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.