HTML和php连数据库后登录跳转代码
例如代码是这样的<?phperror_reporting(E_ALL&~E_NOTICE);if(isset($_POST['submit'])){$username=$...
例如代码是这样的
<?php
error_reporting(E_ALL &~E_NOTICE);
if(isset($_POST['submit'])){
$username = $_POST['username'];
$password = $_POST['password'];
$link = mysql_connect('localhost','root','root');
//echo "aa";
$db_select=mysql_select_db("dormitory",$link);
mysql_query("set characterset gb2312");
$sql="select * from zhuc";
//echo $sql;
$sql1="select mima from zhuc where name='{$_POST['username']}'";
$result = mysql_query($sql);
//echo $sql1;
$presult = mysql_query($sql1);
while(list($user,$pass) = mysql_fetch_row($result)){
if($user==$username&&$pass==$password){
$header("location:main.php");
/*<script>
location.href="main.html";
</script>; */
}
}
mysql_close($link);
}
?>
问题的关键是,点了它还是不跳 展开
<?php
error_reporting(E_ALL &~E_NOTICE);
if(isset($_POST['submit'])){
$username = $_POST['username'];
$password = $_POST['password'];
$link = mysql_connect('localhost','root','root');
//echo "aa";
$db_select=mysql_select_db("dormitory",$link);
mysql_query("set characterset gb2312");
$sql="select * from zhuc";
//echo $sql;
$sql1="select mima from zhuc where name='{$_POST['username']}'";
$result = mysql_query($sql);
//echo $sql1;
$presult = mysql_query($sql1);
while(list($user,$pass) = mysql_fetch_row($result)){
if($user==$username&&$pass==$password){
$header("location:main.php");
/*<script>
location.href="main.html";
</script>; */
}
}
mysql_close($link);
}
?>
问题的关键是,点了它还是不跳 展开
2个回答
展开全部
//转到一个新地址
header('Location: http://www.baidu.com/');
不用加 $ 因为header()是一个函数,而不是变量.
更多追问追答
追问
去掉了还是不行
追答
$link = mysql_connect('localhost','root','root');
//echo "aa";
mysql_select_db("test",$link);
mysql_query("set names utf8");
$sql="select * from tcolor";
//echo $sql;
$result = mysql_query($sql);
//echo $sql1;
if($result!=false){
header("location:1.php");
}
我打开这个页面后,直接就跳转到了1.php
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |