PHP会话控制mysql判断

WBOY
Release: 2016-06-23 13:35:44
Original
1040 people have browsed it

比如我post过来的用户和密码以后需要到数据库里面对比,然后我的sql是这样的

$sql="select user,pass from user where user='$user' and pass='$pwd'";$result=mysql_query($sql);//下面的我就不知道怎么做了,上面的$result应该返回一个结果集的,如果这个SQL执行以后里面有值用IF应该怎么判断呢if($result){  //这个地方应该在来判断$result里面的值呢,我不知道这个地方,是判断布尔值还是判断返回值是多少   setcookie('user',$user,time()+3600);   setcookie('login','2',time()+3600);}
Copy after login


回复讨论(解决方案)

$sql="select user,pass from user where user='$user' and pass='$pwd'"; $result=mysql_query($sql);//下面的我就不知道怎么做了,上面的$result应该返回一个结果集的,如果这个SQL执行以后里面有值用IF应该怎么判断呢 if(mysql_num_rows($result) == 1){  //这个地方应该在来判断$result里面的值呢,我不知道这个地方,是判断布尔值还是判断返回值是多少   setcookie('user',$user,time()+3600);   setcookie('login','2',time()+3600);}
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template