mysql - login form php code -


i have created form username , password , login button in html. have created code php not able check condition login successfull, below php code. satisfying conditions except login successfull. guess there simple mistake in , not able find it, please me.

<?php         include_once('db.php');           $username = mysql_real_escape_string( $_post["username"] );         $password = mysql_real_escape_string( md5($_post["pass"]) );          if( empty($username) || empty($password) )             echo "username , password mandatory ";         else         {         $sql = "select count(*) users where( username='$username' , password='$password')";           $res = mysql_query($sql);         $row = mysql_fetch_array($res);          if( $row[0] > 0 )          echo "login successful";         else          echo "failed login";         }        ?> 

propably, have use following command instead of $row[0] > 0:

mysql_num_rows($sql)

you can check user this:

if(mysql_num_rows($res)==1)   echo "login successful"; } else {   echo "failed login"; } 

Comments

Popular posts from this blog

vue.js - Create hooks for automated testing -

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

javascript - Create a stacked percentage column -