Advertisement
Guest User

Untitled

a guest
Jul 14th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.53 KB | None | 0 0
  1. conexionPOO.php
  2. <?php
  3. class BaseDeDatos {
  4.  
  5.     //Conexión con la base de datos
  6.  
  7.     private $dbhost = 'localhost';
  8.     private $dbuser = 'root';
  9.     private $dbpass = '';
  10.     private $dbname = 'asovifacampe';
  11.  
  12.  
  13.     public function conexion () {
  14.  
  15.         $conexion = new mysqli($this->dbhost,$this->dbuser,$this->dbpass,$this->dbname);
  16.  
  17.         if ($conexion ->connect_error) {
  18.  
  19.             echo "Error de Connexion ($conexion->connect_errno): $conexion->connect_error\n";
  20.  
  21.             exit;
  22.  
  23.         } else {
  24.             return $conexion;
  25.         }
  26.  
  27.     }
  28.  
  29.     public function registrar($sql){
  30.        
  31.         return $this->$conexion->query($sql);
  32.  
  33.     }
  34.  
  35. }
  36. ?>
  37.  
  38.  
  39. verifylogin.php
  40. <?php
  41.  
  42. $email = $_GET['email'];
  43. $passwordLogin = $_GET['passwordLogin'];
  44.  
  45. if($email && $passwordLogin){
  46.     LoginAdmin();
  47.  
  48. }else{
  49.     echo"<script type='text/javascript'>var status = 1; </script>";
  50. }
  51.  
  52. function LoginAdmin(){
  53.     require_once 'conexionPOO.php';
  54.     $conexion = new BaseDeDatos;
  55.     $conexion->conexion();
  56.  
  57.     $sql= "SELECT * FROM admin";
  58.     $result=$conexion->query($sql);
  59.     if($result->num_rows>0){
  60.  
  61.         while($data=$result->fetch_array(MYSQLI_ASSOC)){
  62.  
  63.             $id=$data['idAdmin'];
  64.             $email=$data['email'];
  65.             $password=$data['password'];
  66.  
  67.             if(password_verify($passwordLogin,$password)){
  68.                 echo"<script type='text/javascript'>
  69.          
  70.                          window.location='http://localhost/martin/copiasegura/admin/';
  71.                          
  72.                          </script>";
  73.             }else{
  74.                 echo"<script type='text/javascript'>var status = 2; </script>";
  75.             }
  76.  
  77.         }
  78.     }else{
  79.         LoginUsers();
  80.     }
  81. }
  82. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement