Advertisement
Guest User

Untitled

a guest
Aug 14th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. <?php
  2. class conexion{
  3. private $conexion;
  4. private $server= "localhost";
  5. private $usuario= "root";
  6. private $pass= "";
  7. private $db= "senaconnection";
  8. private $user;
  9. private $password;
  10.  
  11. public function __construct(){
  12. $this->conexion= new mysqli($this->server,$this->usuario,$this->pass,$this->db);
  13. if ($this->conexion->connect_errno) {
  14. die("Fallo al tratar de conectar con MySQL: (".$this->conexion->connect_errno.")");
  15. }
  16. }
  17. public function cerrar(){
  18. $this->conexion->close();
  19. }
  20. public function login($email,$pass){
  21. $this->user= $email;
  22. $this->password= $pass;
  23.  
  24. $query="select id_usuario,nombres,apellidos,correo_sena,contraseña from usuario where correo_sena='".$this->user."' and contraseña='".$this->password."'";
  25. $consulta=$this->conexion->query($query);
  26.  
  27. if ($row = mysqli_fetch_array($consulta)) {
  28. session_start();
  29.  
  30. $_SESSION['id']= $row['id_usuario'];
  31. $_SESSION['nom']= $row['nombres'];
  32. $_SESSION['ape']= $row['apellidos'];
  33.  
  34. echo "Has iniciado sesion";
  35.  
  36. echo $_SESSION['id'];
  37. echo $_SESSION['nom'];
  38. echo $_SESSION['ape'];
  39.  
  40. }else{
  41.  
  42. echo "usuario o contraseña incorrectos";
  43. }
  44.  
  45.  
  46.  
  47. }
  48.  
  49. }
  50.  
  51.  
  52.  
  53.  
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement