mysql - Php login code not reading from database -


this question has answer here:

im trying make login php android app, modified php tutorial, issue used response of "success" = 0 "message"= "not fields filled", added few print_r see problem result aimatosnintendo , inputs username , password, it's not getting ifs, code:

<?php // array json response $response = array(); define('db_user', ""); // db user define('db_password', ""); // db password (mention db password here) define('db_database', ""); // database name define('db_server', ""); // db server // array json response  $conn = new mysqli(db_server, db_user, db_password,db_database);  // check post data print_r ($_post['username']); print_r ($_post['password']);  if(isset($_post['username'],$_post['password'])) {     $username = $_post["username"];     $password = $_post["password"];   $sql = "select *from login username = $username , password = $password"; $result = $conn->query($sql) or die (mysqli_connect_error());  print_r ($username);      if (!empty($result)) {         // check empty result          if (mysqli_num_rows($result) > 0) {              $result = mysqli_fetch_array($result);              $loginfo = array();             $loginfo["name"] = $result["name"];             $loginfo["username"] = $result["username"];             $loginfo["password"] = $result["password"];             $loginfo["phone"] = $result["phone"];             $loginfo["email"] = $result["email"];             $loginfo["license"] = $result["license"];             //$loginfo["expiration"] = $result["expiration"];               // success             $response["success"] = 1;              // user node             $response["logina"] = array();              array_push($response["logina"], $loginfo);              // echoing json response             echo json_encode($response);         } else {             // no product found             $response["success"] = 0;             $response["message"] = "wronglogin";              // echo no users json             echo json_encode($response);         }     } else {         // no product found         $response["success"] = 0;         $response["message"] = "wronglogin";          // echo no users json         echo json_encode($response);     } } else {     // required field missing      $response["success"] = 0;     $response["message"] = "not fields filled";       // echoing json response     echo json_encode($response); } ?> 

db user password server , name correct deleted them in post safety, have code register info on database , works 1 gets me stuck

im expecting $response["success"] = 1; when username , password match database

try

$sql = "select * login username = '". $username ."' , password = '".$password."'"; 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -