php连接数据库成功,但是无法查询到表,为什么?急!!!!!!
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
session_start();
$con = mysqli_connect('localhost', 'root', '', 'beauty') or die("error");//连接数据库
if($con){
echo "成功";
}
$name="";
$psd="";
if((isset($_POST['username']))&&(isset($_POST['password']))){
$name=$_POST["username"];
$psd=$_POST["password"];
if($name==""||$psd==""){
echo "<script>alert('请输入用户名或密码!');history.go(-1);</script>";
}
else{
$sql="select * from domuser where username=`$name` and password=`$psd` ";
$result = mysqli_query($con,$sql);
$num = mysql_num_rows($result);
if ($num) {
$row = mysqli_fetch_array($result); //将数据以索引方式储存在数组中
echo "<script>alert('登录成功!');window.location='index.html';</script>";
} else {
/*echo "<script>alert('用户名或密码不正确!');history.go(-1);</script>";*/
}
}
}
?>