Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.81 KB | None | 0 0
  1.             $connection = Database::getInstance()->OpenConnection();
  2.             $sql = "select * from user where user_name = ? and password = ?;";
  3.             $statement = $connection->prepare($sql);
  4.                
  5.             //if any error happen in connection
  6.             if (!$statement) {
  7.                 echo 'erro na consulta: '. $connection->errno .' - '. $connection->error;
  8.             }
  9.                
  10.             //associate the user name and password with sql parameters,
  11.             //execute the query and store the result
  12.             $statement->bind_param('ss', $user,$password);
  13.             $statement->execute();
  14.             $result = $statement->get_result();
  15.                
  16.             $user;
  17.             //create and set the user variable
  18.             while($row = mysqli_fetch_array($result)){
  19.                 $user = new User($row["idUser"], $row["name"], $row["email"], $row["user_name"], $row["password"], $row["type"], $row["active"], $row["idAdministrator"]);
  20.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement