学了没多久,从网上找了个小留言板代码,对照着写了,写完了发现有问题,session传不过来,我找了好长时间,觉得是这段代码问题,中间最乱那一段,不知道是不是[code=PHP]$result = mysql_query($sql);
$num = mysql_num_rows($result);if($num>0){
while($row = mysql_fetch_array($result))
{
//echo print_r($row);
if($row[2]=="男")//这个使性别改成你想要的名称^_^
{
$sex = "帅锅";
}
else
{
$sex = "美女";
}
?><div id="show">
<p class="num">第 [<?= $row[0] ?>] 条留言<p>
<p class="unline">留言人:<span class="blue"><?= $row[1]?></span> 性别:<?= $sex ?> 留言时间:<?= $row[7] ?> <? if($row[3]) {?> <a href="http://wpa.qq.com/msgrd?V=1&Uin=<?= $row[3] ?>&Site=http://www.loai.cn&Menu=yes"><img src="img/qq.gif" alt="<?= $row[3]?>" /></a><? } ?><? if($row[4]){ ?> <a href="mailto:<?= $row[4] ?>"><img src="img/email.gif" alt="<?= $row[4]?>" /></a> <? }?><? if($_SESSION["key"]==1){ ?> IP:<?= $row[6] ?> <a href="update.php?wuleying&id=<?= $row[0]?>">更改</a> <a href="delete.php?wuleying&id=<?= $row[0]?>">删除</a><?}?></a></p>
<p class="blue">留言内容:</p>
<div id="show_info"><?= nl2br(htmlspecialchars($row[5])) ?></div>
</div>
<?php
}
}
else
{
echo "<div id=\"show\">无数据......</div>";
}
?>
$num = mysql_num_rows($result);if($num>0){
while($row = mysql_fetch_array($result))
{
//echo print_r($row);
if($row[2]=="男")//这个使性别改成你想要的名称^_^
{
$sex = "帅锅";
}
else
{
$sex = "美女";
}
?><div id="show">
<p class="num">第 [<?= $row[0] ?>] 条留言<p>
<p class="unline">留言人:<span class="blue"><?= $row[1]?></span> 性别:<?= $sex ?> 留言时间:<?= $row[7] ?> <? if($row[3]) {?> <a href="http://wpa.qq.com/msgrd?V=1&Uin=<?= $row[3] ?>&Site=http://www.loai.cn&Menu=yes"><img src="img/qq.gif" alt="<?= $row[3]?>" /></a><? } ?><? if($row[4]){ ?> <a href="mailto:<?= $row[4] ?>"><img src="img/email.gif" alt="<?= $row[4]?>" /></a> <? }?><? if($_SESSION["key"]==1){ ?> IP:<?= $row[6] ?> <a href="update.php?wuleying&id=<?= $row[0]?>">更改</a> <a href="delete.php?wuleying&id=<?= $row[0]?>">删除</a><?}?></a></p>
<p class="blue">留言内容:</p>
<div id="show_info"><?= nl2br(htmlspecialchars($row[5])) ?></div>
</div>
<?php
}
}
else
{
echo "<div id=\"show\">无数据......</div>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
...
<?php
session_start();
if($_SESSION['key'] == $name)
{
?>
<li><a href = "adminexit.php">退出管理</a></li>
<?php
}
else
{
?>
<li><a href = "admin.php">偶要管理</a></li>问:怎样点退出管理就退出登陆?adminexit.php怎么写?
session_destroy(); //销毁所有的session变量,即退出登录
header("Location: /"); //退出登录后跳转到某个页面,比如网站首页
我是看这个代码网站写的,帮我看一下吧!
http://www.xkzzz.com/zz/netbc/php/200903/05-10010.htm