尝试为我的网站上的注册用户编写控制面板代码,但我卡住了。好吧,我无法弄清楚我做错了什么。我有一个登录系统,我正在使用会话。我使用会话代码绘制与登录角色有关的特定值。我可以获取要显示的用户名,但不能尝试从数据库中绘制的其他字段。我的代码就像休耕一样。
<?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>
答案 0 :(得分:2)
记住你总是要把
session_start();