not working

0 MAYANK JINDAL · May 10, 2015
This code is always showing fail,please help me - 
<?php
 
 if(isset($_POST['username']) && isset($_POST['password'])){
  $username = $_POST['username'];
  $password =  $_POST['password'];
  $password_hash = md5($password);
 if(!empty($_POST['username']) && !empty($_POST['password'])){
     $query = "SELECT 'id' FROM 'users' WHERE 'username' = '$username' AND 'password' = '$password_hash' ";
     if($query_run = mysql_query($query)){
      $query_num_rows = mysql_num_rows($query_run);
      if($query_num_rows==0){
             echo 'invalid data';
      }
      else if($query_num_rows==1) {
            echo 'ok';
      }
     }
     else{
      echo 'fail';
     }
      }
      


      else{
              echo 'fill details';
      } 
 }

?>

<form action = "<?php echo $current_file ; ?>" method = "POST">
username : <input type= 'text' name = 'username'>  password : <input type ='password'  name = 'password'>
  <input type = 'submit' value ='login'>

</form>

Post a Reply

Replies

Oldest  Newest  Rating
0 Logan Lohman · May 11, 2015
Are you receiving any errors?
  • 1

PHP

107,260 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators