Advertisement
Guest User

Untitled

a guest
Mar 1st, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. <?php
  2.  
  3. $this->conexion = new mysqli($this->host, $this->user,$this->pw,$this->bd);
  4.  
  5. if($this->conexion->connect_errno){
  6. die("fallo al tratar de conectar con MYSQL: (". $this->conexion->connect_errno.")");
  7.  
  8. }
  9. }
  10.  
  11. public function cerrar(){
  12. $this->conexion->close();
  13. }
  14.  
  15. public function login($usuario, $contrasena){
  16.  
  17. $this->usuario = $usuario;
  18. $this->password = $contrasena;
  19.  
  20. $query= "select nombre, apellido from usuario where nombre='".$this->usuario."' or correo='".$this->usuario."' and contrasena='".$this->password."'";
  21.  
  22. $consulta = $this->conexion->query($query);
  23.  
  24. if($row = mysqli_fetch_array($consulta)){
  25.  
  26. session_start();
  27.  
  28. $_session['nombre'] = $row['nombre'];
  29. $_session['apellido'] = $row['apellido'];
  30.  
  31. echo "has iniciado Sesion";
  32.  
  33.  
  34. }
  35. else{
  36. echo "usuario o contraseña incorrectos";
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement