注册 登录
编程论坛 PHP技术论坛

页面不能自动跳转

swm12345 发布于 2006-11-01 17:27, 1126 次点击

每次输入正确的用户名和密码后,都会出现空白页,而不跳转到指定的mainad.php,请问哪里出错了,没检查出来

<?php
$user=$_POST['user'];
$password=$_POST['password'];
if(isset($user) && strlen($user) > 0)
{
mysql_connect("localhost", "wyzx", "songzhiyuan");
mysql_select_db("wyzx") or die ("不能连接到数据库!");
$strSql = "SELECT * FROM user where user='$user' and password='$password';";
$result=mysql_query($strSql);
$num=mysql_fetch_array($result);

if(!empty($num[0]))
{
require("mainad.php");
}
else
{
require("login.php");
}
}
?>

2 回复
#2
MicroSoft2006-11-02 22:42
以下是引用swm12345在2006-11-1 17:27:24的发言:

每次输入正确的用户名和密码后,都会出现空白页,而不跳转到指定的mainad.php,请问哪里出错了,没检查出来

<?php
$user=$_POST['user'];
$password=$_POST['password'];
if(isset($user) && strlen($user) > 0)
{
mysql_connect("localhost", "wyzx", "songzhiyuan");
mysql_select_db("wyzx") or die ("不能连接到数据库!");
$strSql = "SELECT * FROM user where user='$user' and password='$password';";
$result=mysql_query($strSql);
$num=mysql_fetch_array($result);

if(!empty($num[0]))
{
header("Location: mainad.php");
}
else
{
header("Location:login.php");
}
}
?>

这样测试

#3
MicroSoft2006-11-02 22:44
在我的印象中require不是重定向,而是包含文件的意思
不知道我记的对不对
1