我在这里要做的是显示我的登录信息,并在登录后显示其他内容
示例在这里
<?php
$user = JFactory::getUser();
$status = $user->guest;
if($status == 1){
echo '
<form id="login-form" class="form-inline" method="post" action="/home">
<div class="topUser">
Name:
<input id="modlgn-username" class="TopinputReg" type="text" placeholder="User Name" tabindex="0" name="username" />
</div>
<div class="toppass">Password:
<input id="modlgn-passwd" class="TopinputReg" type="password" placeholder="Password" tabindex="0" name="password" pwfprops="," />
</div>
<div class="topsignin">
<input class="Signin" name="Submit" tabindex="0" type="submit" value="" />
</div>
<div class="topregister">
<a href="http://gamers-league.com/forums/user/register"><input name="button" type="submit" class="Register" id="button" value="" /></a>
</div>
<input type="hidden" value="com_users" name="option">
<input type="hidden" value="user.login" name="task">
<input type="hidden" value="aW5kZXgucGhwP0l0ZW1pZD0xMzM=" name="return">
<input type="hidden" value="1" name="39ea5446d876078c6f6221d396ef5bd4">
</form>
';
}
else
{
echo '
<div class="topUser">Welcome Back!</div>
<div class="toppass">Enjoy you stay.</div>
<form id="login-form" class="form-vertical" method="post" action="/log-out">
<div class="topsignin">
<input class="Signout" type="submit" value="" name="Submit" />
<input type="hidden" value="com_users" name="option">
</div>
<input type="hidden" value="com_users" name="option">
<input type="hidden" value="user.logout" name="task">
<input type="hidden" value="aW5kZXgucGhwP0l0ZW1pZD0xMDE=" name="return">
<input type="hidden" value="1" name="994c61f8ab4ccf23fe9dae6546a87089">
</form>
<div class="topregister">
<a href="http://gamers-league.com/forums/user"><input name="button" type="submit" class="account" id="button" value="" /></a>
</div>
';
}
?>
不,我知道我做错了什么,只是不知道如何解决它。两个
每次需要生成不同的数字,但我该怎么做。
因为这个数字每次都是相同的,如果我登录然后再尝试重新登录它会给我“无效令牌”
当我进入登录模板时,它给了我 这个用于登录
<input type="hidden" name="return" value="<?php echo base64_encode($this->params->get('login_redirect_url', $this->form->getValue('return'))); ?>" />
<?php echo JHtml::_('form.token'); ?>
这用于注销
<input type="hidden" name="return" value="<?php echo base64_encode($this->params->get('logout_redirect_url', $this->form->getValue('return'))); ?>" />
<?php echo JHtml::_('form.token'); ?>
现在,如果我在尝试刷新页面时用上面的php内容替换已经具有预生成数字的隐藏字段,那么它将完全空白。
我对此感到茫然,看看我在php中是不是很先进。任何人都无法提供任何帮助将会非常有帮助..
答案 0 :(得分:0)
为什么不尝试这样,
<?php
$user = JFactory::getUser();
$status = $user->guest;
if($status == 1):
?>
<form id="login-form" class="form-inline" method="post" action="/home">
<div class="topUser">
Name:
<input id="modlgn-username" class="TopinputReg" type="text" placeholder="User Name" tabindex="0" name="username" />
</div>
<div class="toppass">Password:
<input id="modlgn-passwd" class="TopinputReg" type="password" placeholder="Password" tabindex="0" name="password" pwfprops="," />
</div>
<div class="topsignin">
<input class="Signin" name="Submit" tabindex="0" type="submit" value="" />
</div>
<div class="topregister">
<a href="http://gamers-league.com/forums/user/register"><input name="button" type="submit" class="Register" id="button" value="" /></a>
</div>
<input type="hidden" value="com_users" name="option">
<input type="hidden" value="user.login" name="task">
<input type="hidden" name="return" value="<?php echo base64_encode($this->params->get('login_redirect_url', $this->form->getValue('return'))); ?>" />
<?php echo JHtml::_('form.token'); ?>
</form>
<?php else:
?>
<div class="topUser">Welcome Back!</div>
<div class="toppass">Enjoy you stay.</div>
<form id="login-form" class="form-vertical" method="post" action="/log-out">
<div class="topsignin">
<input class="Signout" type="submit" value="" name="Submit" />
<input type="hidden" value="com_users" name="option">
</div>
<input type="hidden" value="com_users" name="option">
<input type="hidden" value="user.logout" name="task">
<input type="hidden" name="return" value="<?php echo base64_encode($this->params->get('logout_redirect_url', $this->form->getValue('return'))); ?>" />
<?php echo JHtml::_('form.token'); ?>
</form>
<div class="topregister">
<a href="http://gamers-league.com/forums/user"><input name="button" type="submit" class="account" id="button" value="" /></a>
</div>
<?php endif;?>