PHP Classes

File: login.php

Recommend this page to a friend!
  Classes of Yerfry Ramirez  >  Simple PHP OOP CMS  >  login.php  >  Download  
File: login.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Simple PHP OOP CMS
Build Web site pages from template classes
Author: By
Last change: Update login.php
Date: 6 years ago
Size: 882 bytes
 

Contents

Class file image Download
<?php
require 'config.php';

if(
Session::exists('UserData')) header('Location: index.php');

$Template = new Template();
$Member = new User();

if(isset(
$_POST['Login'])) {
   
$Username = stripslashes($_POST['username']);
   
$Password = stripslashes($_POST['password']);

   
$lsPassword = strtolower($Password);

    if(
$Member::userExists($Username)):
       
$UserData = $Member::GetUserDataFrom('Username', $Username);
       
$Encrypted = Functions::encryptPassword($lsPassword, $UserData['Unique_id']);

        if(
$UserData['Password'] == $Encrypted):
           
Database::update('users', "Password = '{$Encrypted}'", ['UserIP' => $Member::$UserIP]);
           
Session::set('UserData', $UserData);

            echo
'You\'ve been logged in';
           
header('Refresh: 1.5; Url=index.php');
        else:
            echo
'Wrong password';
        endif;
    else:
        echo
'The username does not exist';
    endif;
}

$Template->file('login.html')->render();
?>

For more information send a message to info at phpclasses dot org.