我想要的「登錄/註冊」按鈕,在導航欄在用戶登錄後更改爲「我的賬戶」。導航欄
的navigation.php文件我目前使用此看起來是這樣的:
<?php
session_start();
include("check.php");
?>
<?php
if ($_SESSION['username']){ ?>
<div id="nav">
<ul >
<li class="navbar-left"><a href="artikelen.html">Men</a></li>
<li class="navbar-left"><a href="artikelen.html">Women</a></li>
<li class="navbar-left"><a href="artikelen.html">Kids</a></li>
<li class="navbar-right"><a href="view_cart.php">Cart (0)</a></li>
<li class="navbar-right"><a href="inlog.php">My Account</a></li>
</ul>
</div>
<?php } else { ?>
<div id="nav">
<ul >
<li class="navbar-left"><a href="artikelen.html">Men</a></li>
<li class="navbar-left"><a href="artikelen.html">Women</a></li>
<li class="navbar-left"><a href="artikelen.html">Kids</a></li>
<li class="navbar-right"><a href="view_cart.php">Cart (0)</a></li>
<li class="navbar-right"><a href="inlog.php">Login/Sign Up</a></li>
</ul>
</div>
<?php }
?>
的check.php文件看起來是這樣的:
<?php
include('connection.php');
session_start();
$user_check=$_SESSION['username'];
$ses_sql = mysqli_query($db,"SELECT username FROM users WHERE username='$user_check' ");
$row=mysqli_fetch_array($ses_sql,MYSQLI_ASSOC);
$login_user=$row['username'];
if(!isset($user_check))
{
header("Location: index.php");
}
?>
如果我去一個網頁,這個導航欄我得到以下錯誤:
This webpage has a redirect loop ERR_TOO_MANY_REDIRECTS
有人能幫我嗎?