Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. */
  5. class conexion
  6. {
  7.  
  8. private $conexion;
  9. private $server="localhost";
  10. private $usuario="root";
  11. private $pass="";
  12. private $bd="login";
  13. private $user;
  14. private $password;
  15.  
  16. function __construct(){
  17.  
  18. $this->conexion = new MySQli($this->server,$this->usuario,$this->pass,$this->bd);
  19. if($this->conexion->connect_errno){
  20.  
  21. die("Algo a salido mal con MySQli (".$this->conexion->connect_errno.")");
  22.  
  23. }
  24.  
  25. }
  26.  
  27. public function cerrar(){
  28. $this->conexion->close();
  29. }
  30.  
  31. public function login($usuario,$pass){
  32. $this->user=$usuario;
  33. $this->password=$pass;
  34.  
  35. $query=("select id,Usuario,Password from login where Usuario= '".$this->user."' and Password= '".$this->password."'");
  36. $consulta=$this->conexion->query($query);
  37. if(mysqli_num_rows($consulta)>0){
  38. if($row=mysqli_fech_array($consulta)){
  39. echo "Has iniciado sesión correctamente";
  40. }else{
  41.  
  42. echo"Los datos son incorrectos";
  43.  
  44. }
  45.  
  46. }else{
  47.  
  48. echo "eso esta mal";
  49.  
  50. }
  51.  
  52. }
  53. }
  54.  
  55. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement