Jump to content

... Just a little output question?


Solarpitch

Recommended Posts

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

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?

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

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!

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.