当有人登录时,我正尝试将我页面上的登录按钮更改为退出按钮。
$logged_in = $this->session->userdata('logged_in');
if ($logged_in) {
$data['Lbutton'] = '<div id="login">
<button class="login3"><?php echo anchor("pages/logout", "Logout"); ?></button>
</div>';
} else {
$data['Lbutton'] = '<div id="login">
<button class="login3"><a href= <?php echo base_url()?>index.php/login>login</a> </button>
</div>';
}
这是我的观点:
<?php echo $Lbutton ?>
答案 0 :(得分:0)
这是答案:
if ($logged_in)
{
$data['Lbutton'] = '<div id="login">
<button class="login3">'.anchor("pages/logout", "Logout").'</button>
</div>';
}
else
{
$data['Lbutton'] = '<div id="login">
<button class="login3"><a href="'.base_url().'index.php/login" >login</a> </button>
</div>';
}