Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- require_once('../includes/config.php');
- $conn=mysql_connect(DB_HOST,DB_USER,DB_PASS);
- mysql_select_db(DB_BASE);
- require_once('../classes/admin.class.php');
- require_once('../classes/sessions.class.php');
- $admin = new Admin();
- $sessions = new Sessions();
- function protect($string) {
- $string = trim(mysql_escape_string($string));
- return $string;
- }
- if (isset($_POST['loginSubmit']) && $_POST['loginClick'] == 1) {
- $errors = array();
- if(empty($_POST['username'])) {
- $errors['username'] = 'You must provide your username.';
- }
- if(empty($_POST['password'])) {
- $errors['password'] = 'You must provide your password.';
- }
- if(empty($errors)) {
- $username = protect($_POST['username']);
- $password = protect($_POST['password']);
- //First check to make sure that admin exists
- $adminExists = $admin->adminExists($username, $password);
- //If admin does exist, check to see if they are already loggedin
- if ($adminExists['exists'] == 1) {
- $uid = $adminExists['uid'];
- $logCheck = $admin->adminLoggedin($uid);
- //If they are already logged in, log them out and then log them back in
- if ($logCheck['count'] == 1) {
- $id = $logCheck['logID'];
- $sessions->adminLogout($id);
- $sessions->adminLogin($uid);
- header("Location:main.php");
- }
- else {
- $sessions->adminLogin($uid);
- header("Location:main.php");
- }
- }
- else {
- $errors['notExist'] = 'The username and/or password you\'ve provided are incorrect. Please try again.';
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement