MySQL,php 用户登录界面代码什么地方错了
//用户登录界面,大神帮我看以看哪里有什么错误还是怎样,mysql我看了看也正确的,但是我输出的东西都显示不出来什么原因呀<!doctypehtml><html><hea...
//用户登录界面 ,大神帮我看以看哪里有什么错误还是怎样,mysql我看了看也正确的,但是我输出的东西都显示不出来 什么原因呀
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<link rel="stylesheet" type="text/css" href="style/common.css">
</head>
<body>
<?php
if(isset($_post['button']))
{
$username=$_post['username'];
$password=$_post['password'];
mysql_connect('127.0.0.1','root','')or die(mysql_error());
mysql_select_db('data');
mysql_query('set name utf8');
$sql="select * from `user` where username='$username' and `password`='$password'";
$rs=mysqli_query($sql);
if(mysqli_num_rows($rs)==1)
{
header('location:showgoods.php');
}
else
{
echo '登录失败';
}
}
?>
<form name="form1" method="post" action="">
<table width="500" border="1" align="center">
<tr>
<th colspan="2">用户登录</th>
</tr>
<tr>
<td>用户名:</td>
<td><label for="username"></label>
<input name="username" type="text" id="username"></td>
</tr>
<tr>
<td>密码:</td>
<td><label for="textfield2"></label>
<input name="password" type="password" id="textfield2"></td>
</tr>
<tr>
<td colspan="2" align="center"><label for="password">
<input type="submit" name="button" id="button" value="提交">
</label></td>
</tr>
</table>
</form>
</body>
</html> 展开
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<link rel="stylesheet" type="text/css" href="style/common.css">
</head>
<body>
<?php
if(isset($_post['button']))
{
$username=$_post['username'];
$password=$_post['password'];
mysql_connect('127.0.0.1','root','')or die(mysql_error());
mysql_select_db('data');
mysql_query('set name utf8');
$sql="select * from `user` where username='$username' and `password`='$password'";
$rs=mysqli_query($sql);
if(mysqli_num_rows($rs)==1)
{
header('location:showgoods.php');
}
else
{
echo '登录失败';
}
}
?>
<form name="form1" method="post" action="">
<table width="500" border="1" align="center">
<tr>
<th colspan="2">用户登录</th>
</tr>
<tr>
<td>用户名:</td>
<td><label for="username"></label>
<input name="username" type="text" id="username"></td>
</tr>
<tr>
<td>密码:</td>
<td><label for="textfield2"></label>
<input name="password" type="password" id="textfield2"></td>
</tr>
<tr>
<td colspan="2" align="center"><label for="password">
<input type="submit" name="button" id="button" value="提交">
</label></td>
</tr>
</table>
</form>
</body>
</html> 展开
1个回答
展开全部
内容:
$username=$_POST['username'];
$password=$_POST['password'];
mysql_connect('127.0.0.1','root','')or die(mysql_error());
mysql_select_db('data');
mysql_query('set names utf8');
$sql="select * from `user` where username='$username' and `password`='$password'";
$rs=mysql_query($sql);
if(mysql_num_rows($rs)==1)
{
header('location:showgoods.php');
}
else
{
echo '登录失败';
}
日期:2015年10月26日 11:38:54
追问
我看也没什么错误呀,而且你发的这个代码和我php代码是一样的呀
追答
补充:你确定一样?
日期:2015年10月26日 13:48:08
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询