<?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();
?>
|