Advertisement
Guest User

Untitled

a guest
Apr 7th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. <?php
  2.  
  3. class Acceso{
  4. protected $user;
  5. protected $pass;
  6.  
  7. public function __construct($usuario,$password){
  8. $this->user = $usuario;
  9. $this->pass = $password;
  10. }
  11.  
  12. public function Login(){
  13. $db = new Conexion();
  14. $sql = $db->query("SELECT nombre,password FROM usuarios WHERE nombre='$this->user' OR password='$this->pass'; ");
  15. $dato = $db->recorrer($sql);
  16.  
  17. if(strtolower($dato['nombre']) == $this->user and strtolower($dato['password']) == $this->pass){
  18. session_start();
  19. $_SESSION['user'] = $this->user;
  20. header('location: acceso.php')
  21.  
  22. }else{
  23. header('location: index.php?error=datos_incorrectos');
  24. }
  25.  
  26. }
  27.  
  28. ?>
  29.  
  30. <?php
  31. class Conexion extends mysqli{
  32. public function __construct(){
  33. parent::__construct('localhost','root','','prinick');
  34. $this->query("SET NAMES 'utf8';");
  35. $this->connect_errno ? die("Error de la Conexion"): $x = "SE Conecto";
  36. // echo $x;
  37. unset($x);
  38. }
  39. }
  40.  
  41. public function recorrer($y){
  42. return mysqli_fetch_array($y);
  43. }
  44. // $db = new Conexion();
  45.  
  46.  
  47.  
  48. ?>
  49.  
  50. <?php
  51. class Conexion extends mysqli
  52. {
  53. public function __construct()
  54. {
  55. parent::__construct('localhost', 'root', '', 'prinick');
  56. $this->query("SET NAMES 'utf8';");
  57. $this->connect_errno ? die("Error de la Conexion") : $x="SE Conecto";
  58. // echo $x;
  59. unset($x);
  60. }
  61.  
  62.  
  63. public function recorrer($y)
  64. {
  65. return mysqli_fetch_array($y);
  66. }
  67.  
  68. }
  69. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement