PHP session control mysql judgment

Source: Internet
Author: User
Tags php session
PHP session control mysql determines that the user and password I post will be compared in the database, and then my SQL is like this
$ SQL = "select user, pass from user where user = '$ user' and pass =' $ pwd'"; $ result = mysql_query ($ SQL ); // I don't know how to do the following. the above $ result should return a result set, IF the SQL statement has a value after execution, how can we determine if? IF ($ result) {// where should we judge the value in $ result? I don't know where it is, determine the boolean value or the returned value. setcookie ('user', $ user, time () + 3600); setcookie ('login', '2', time () + 3600 );}


Reply to discussion (solution)

$ SQL = "select user, pass from user where user = '$ user' and pass =' $ pwd'"; $ result = mysql_query ($ SQL ); // I don't know how to do the following. the above $ result should return a result set, how should I judge the value of this SQL statement after execution using IF? if (mysql_num_rows ($ result) = 1) {// The value in $ result should be determined here, I don't know whether to determine the boolean value or the number of setcookies ('user', $ user, time () + 3600) returned values; setcookie ('login ', '2', time () + 3600 );}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.