Advertisement
Guest User

logit.php

a guest
Oct 24th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. <?php
  2.     session_start();
  3.    
  4.     include_once('config/config.php');
  5.    
  6.     class User{
  7.        
  8.         private $db;
  9.        
  10.         public function  __construct() {
  11.             $this->db = new Connection();
  12.             $this->db = $this->db->dbConnect();
  13.         }
  14.        
  15.         public function Login($name, $pass) {
  16.             if(!empty($name) && !empty($pass)){
  17.                 $st = $this->db->prepare("SELECT * FROM users WHERE user=? AND pass=?");
  18.                 $st->bindParam(1, $name);
  19.                 $st->bindParam(1, $pass);
  20.                 $st->execute();
  21.                
  22.                 if($st->rowCount() == 1){
  23.                     header('Location: admin/index.php');
  24.                 } else {
  25.                     $_SESSION['errortext'] = '<div class="error_login">Nieprawidłowy login lub hasło!</div>';
  26.                     header('Location: login.php');
  27.                 }
  28.                
  29.            
  30.             } else {
  31.                 $_SESSION['errortext'] = '<div class="error_login">Wpisz swoją nazwę użytkownika oraz hasło!</div>';
  32.             }
  33.         }
  34.        
  35.     }
  36.  
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement