-1

试图在我的网站上为注册用户编写控制面板,但我卡住了。好吧,我不知道我做错了什么。我有一个登录系统,我正在使用会话。我使用会话代码来绘制与登录字符有关的特定值。我可以显示用户名,但不能显示我试图从数据库中提取的其他字段。我的代码是休闲的。

<?php 
 require("common.php"); 
      if(empty($_SESSION['user'])) 
    { 

        header("Location: login.php"); 

        die("Redirecting to login.php"); 
    } 


?> 

<a href="logout.php">Logout</a>  
<center> 
<table border>
<tr>
<td width="120" height="10"><center>Character</center></td>
<td width="120" height="10"><center>Attack</center></td>
<td width="120" height="10"><center>Defence</center></td>
<td width="120" height="10"><center>Strength</center></td>
<td width="120" height="10"><center>Hit points</center></td>
</tr>
<tr>
<td width="120" height="10"><center><?php echo htmlentities($_SESSION['user']['username']); ?></center></td>
<td width="120" height="10"><center><?php echo htmlentities($_SESSION['user']['attack'], ENT_QUOTES, 'UTF-8'); ?></center></td>
<td width="120" height="10"><center><?php echo htmlentities($_SESSION['user']['defence'], ENT_QUOTES, 'UTF-8'); ?></center></td>
<td width="120" height="10"><center><?php echo htmlentities($_SESSION['user']['strength'], ENT_QUOTES, 'UTF-8'); ?>></center></td>
<td width="120" height="10"><center><?php echo htmlentities($_SESSION['user']['hits'], ENT_QUOTES, 'UTF-8'); ?></center></td>
</tr>


</table></center>
4

1 回答 1

2

记住你总是必须把

session_start();
于 2013-11-07T20:59:40.227 回答