session_start()一定要放在页面的最顶吗
我看有的教材是这个
<html>
<head>
<title>留言页面</title>
</head>
<body>
<form method="post" action="">
验证码:<input type="text" size="10" name="check">
<img src="EX4_14_image.php">
<input type="submit" name="ok" value="提交">
</form>
</body>
</html>
<?php
session_start(); //启动session
if(isset($_POST['ok']))
{
$checkstr=$_SESSION['string']; //使用$_SESSION变量获取SY4_5_image.php页面上的验证码
$str=$_POST['check']; //用户输入的字符串
if(strcasecmp($str,$checkstr)==0) //不区分大小写进行比较
echo "<script>alert('验证码输入正确!');</script>";
else
echo "<script>alert('输入错误!');</script>";
}
?>
他把session放在了html下面!!!
哔哔one
largeQ