Advertisement
Guest User

FetchUserData

a guest
Apr 28th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.86 KB | None | 0 0
  1. <?php
  2.     require("password.php");
  3.     $con = mysqli_connect("my_host", "my_user", "my_password", "my_database");
  4.    
  5.     $username = $_POST["username"];
  6.     $password = $_POST["password"];
  7.    
  8.     $statement = mysqli_prepare($con, "SELECT * FROM user WHERE username = ?");
  9.     mysqli_stmt_bind_param($statement, "s", $username);
  10.     mysqli_stmt_execute($statement);
  11.     mysqli_stmt_store_result($statement);
  12.     mysqli_stmt_bind_result($statement, $colUserID, $colName, $colUsername, $colAge, $colPassword);
  13.    
  14.     $response = array();
  15.     $response["success"] = false;  
  16.    
  17.     while(mysqli_stmt_fetch($statement)){
  18.         if (password_verify($password, $colPassword)) {
  19.             $response["success"] = true;  
  20.             $response["name"] = $colName;
  21.             $response["age"] = $colAge;
  22.         }
  23.     }
  24.     echo json_encode($response);
  25. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement