Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Logins extends DB {
- private $table = 'users';
- private $prefix = 'temp_';
- //Encrypt password new.
- private function Cript($Password) {
- return md5($Password);
- }
- //Function account validation
- private function Validate($Email, $Password) {
- $Password = $this->Cript($Password);
- try {
- $Validates = self::Connect()->prepare("SELECT * FROM " . $this->table . " WHERE email = ? AND password = ? AND status='1'");
- $Validates->execute(array($Email, $Password));
- return ($Validates->rowCount() >= 1) ? true : false;
- } catch (PDOException $e) {
- echo $e->getMessage();
- return false;
- }
- }
- //login in panel
- public function LogIn($Email, $Password) {
- if ($this->Validate($Email, $Password)) {
- $_SESSION[$this->prefix . 'email'] = $Email;
- $_SESSION[$this->prefix . 'password'] = $Password;
- return true;
- } else {
- return false;
- }
- }
- //Verifies that is already logged in
- public function isLogged() {
- if (isset($_SESSION[$this->prefix . 'email']) && isset($_SESSION[$this->prefix . 'password'])) {
- return true;
- } else {
- return false;
- }
- }
- public function Logout() {
- if ($this->isLogged()) {
- unset($_SESSION[$this->prefix . 'email']);
- unset($_SESSION[$this->prefix . 'password']);
- session_destroy();
- return true;
- } else {
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment