代码:sql.php
<?php
$uid = trim($_POST['uid']);
$pass= trim($_POST['pass']);
$type= trim($_POST['type']);
$link = mysql_connect("localhost","root","akash");
if (!$link)
die('Could not connect: '.mysql_error());
if(!mysql_select_db("fsproj",$link))
die("Can't Select database");
if ($type == 0 )
$query = "select uid from admin where uid = \"$uid\" AND password = \"$pass\"";
else
$query = "select username from user where uid = $uid AND pass = $pass";
$result = mysql_query("$query",$link);
$num_r=mysql_num_rows($result);
header("Location : codepage.php");
exit();
?>
代码:login.html
<html>
<form action="sql.php" method="post" name="form1" id="form1" target=result>
Enter UID
<textarea name="uid" id="uid" rows="1" cols="40">
</textarea><br>
Password
<textarea name="pass" id="pass" rows="1" cols="40">
</textarea><br>
Type
<textarea name="type" id="type" rows="1" cols="40">
</textarea>
<br>
<input type="submit" value="Submit" />
</form>
</html>
所有文件都在同一个根目录下,通过login.html向sql.php提交用户名和密码应该重定向到文件codepage.php(我还没有添加登录检查,所以对于任何用户名作为密码的值都应该成功)
但是当我尝试这样做时,我得到的只是一个空白页。
如果我在标头调用之后添加一个输出语句,我会看到该语句的输出
基本上header("Location : codepage.php")
没有影响
标头功能在同一站点上的某些其他页面中确实有效