-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth_v2.php
35 lines (33 loc) · 1.08 KB
/
auth_v2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php include_once('includes/load.php'); ?>
<?php
$req_fields = array('username','password' );
validate_fields($req_fields);
$username = remove_junk($_POST['username']);
$password = remove_junk($_POST['password']);
if(empty($errors)){
$user = authenticate_v2($username, $password);
if($user):
// Crear session con id
$session->login($user['id']);
// Actualizar ultima conexion usuario.
updateLastLogIn($user['id']);
// Redirigir al inicio segun el nivel de usuario.
if($user['user_level'] === '1'):
$session->msg("s", "Hello ".$user['username']."");
redirect('admin.php',false);
elseif ($user['user_level'] === '2'):
$session->msg("s", "Hello ".$user['username']."");
redirect('special.php',false);
else:
$session->msg("s", "Hello ".$user['username']."");
redirect('home.php',false);
endif;
else:
$session->msg("d", "Sorry Username/Password incorrect.");
redirect('index.php',false);
endif;
}else{
$session->msg("d", $errors);
redirect('login_v2.php',false);
}
?>