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
Share on other sites

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
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?

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • 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.