<?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数据库用户验证
$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数据库用户验证
解决方案 »
- 求达人开发youtube和其他的视屏的dz7.0 插件--有酬谢!!!
- mysql 比较函数in()如何使用
- PHP程序的图片修改,但是网站浏览还是没修改过来
- 静态html中的尺度
- 数据库大赛题目
- Accept-Encoding : gzip,deflate 这个方式的文件下载下来的文件,怎样操作能得到原文???????????
- 为什么有其他的命令时输出的图形为乱码?
- php中关于类的疑问
- 有谁知道泰文版的网页如何制作?
- 郁闷,我导出的数据库文件因为太大,重新导入的时候总是提示超时,怎么办??
- PHP 检查表单中是否有空值,为什么不起作用
- 帮忙看看这段代码是什么意思?看了1个多小时也没看懂,谢谢!
select count(*)
from user
where username='".$_POST['name']."' and password='".$_POST['password']."'
LIMIT 1
";然后用mysql_num_rows 判断行是否等于1就行。
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]'";
不需要 LIMIT 1
因为没有 group 子句,聚类函数只会取得一条记录对传入的数据做一下转义处理是必须的,在程序入口处这样就可以了
$_POST = array_map('mysql_real_escape_string', $_POST);
一般都要 先判断一下吧比如 ISSET之类的.