Home >Backend Development >PHP Tutorial >能够在登录以后,显示登录名和退出,并且隐藏登录和注册按钮

能够在登录以后,显示登录名和退出,并且隐藏登录和注册按钮

不言
不言Original
2018-05-19 09:37:063365browse

  能够在登录之后,显示登录名和退出,并且隐藏登录和注册按钮
哪位能帮我写个这部分的代码,js也行 或者直接判断session的也行。。小菜鸟写了两天也不显示。。
------解决方案--------------------

<?php if($_SESSION["u_id"]) { ?>
<?php }else{ ?>
<?php } ?>

------解决方案--------------------
在html页面里 添加php的if 判断就可以了

例如

<?php if(&#39;条件&#39;){ ?>
HTML
<?php }else{ ?>
HTML
<?php }?>

------解决方案--------------------

session_start();
$uid=!empty($_SESSION[&#39;uid&#39;]) ? $_SESSION[&#39;uid&#39;] : &#39;&#39;;
$username=!empty($_SESSION[&#39;username&#39;]) ? $_SESSION[&#39;username&#39;] : &#39;&#39;;
if($uid && $username){
echo $username.&#39; 
------解决方案--------------------
 收件箱 
------解决方案--------------------
 设置&#39;;
}else{
if(isset($_POST[&#39;uid&#39;]) && isset($_POST[&#39;username&#39;])){
$_SESSION[&#39;uid&#39;]=$_POST[&#39;uid&#39;];
$_SESSION[&#39;username&#39;]=$_POST[&#39;username&#39;];
echo &#39;<script type="text/javascript">window.location.reload();</script>&#39;;
}else{
?>
你还未登陆:
<form id="form" method="post" action="xx.php">
<input type="text" name="uid" id="uid" value="1"><br>
<input type="text" name="username" id="username" value="admin"><br>
<input type="submit" name="submit" value="submit">
</form>
<?php
}
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn