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 );}