关于PHP数据库的小问题
<?php
$con=mysql_connect("localhost","root","123456");
if(!$con)
{
die('Could not connect:'.mysql_error());
}
mysql_query("SET NAMES 'utf8'"); //设置字符集
mysql_select_db("manage",$con); //选择数据库
$sql1="
select count(*)
from user
where username=="".$_POST['name']."" and password=="".$_POST['password'].""
LIMIT 1
";
$result=mysql_query($sql1,$con);
红色部分报错。前辈们,在下有两个问题:第一,目前这种格式,应该怎么改,使其正确。第二,你们在验证用户信息时,是这么做的呢?比较简单的那种。 PHP 数据库 用户验证
[解决办法]
$sql1="
select count(*)
from user
where username='".$_POST['name']."' and password='".$_POST['password']."'
LIMIT 1
";
$sql1 = "
select count(*)
from user
where username='".$_POST['name']."' and password=='".$_POST['password']."'";
$sql1 = "
select count(*)
from user
where username='$_POST[name]' and password='$_POST[password]'";