If ($model - Row ('User - Hivi') $user && $model - Row ('Pass - Hivi') $pass && $model - Row ('State - User') 1) (
If ($model - Row ('User - Hivi') $user && $model - Row ('Pass - Hivi') $pass && $model - Row ('State - User') 1) (
php
2
3 require_once 'app/models/Database.php';
4
5 class Validate_login {
6
7 public function validateLogin($user,
($user, $pass) {
8 //Instanciamos el modelo...
9 $model = new Database();
10 $model->validar_login($user, $pass);
11 //print_r($model->row);
12 //exit();
13 //Comparamos los datos obtenidos...
14 if ($model->row['user_hivi'] == $user && $model->row['pass_hivi'] == $pass && $model->row['state_user'] == 1) {
15 //Creamos variables de sesion...
16 $_SESSION['sesion_hivi'] = true;
17 $_SESSION['user_hivi'] = $model->row['user_hivi'];
18 $_SESSION['btc_user'] = $model->row['btc_user'];
19 //Redireccionamos al dashboard...
20 header("Location: " . BASE_URL . "home/");
21 } else {
22 //Creamos una variable de error...
23 $_SESSION['notify'] = "<div class='alert alert-dismissible alert-danger'>The account does not exist, check the data and try again.</div>";
24 header("Location: " . BASE_URL . "login/");
25 }
26 }
27
28 }
29
30 if (isset($_POST['login'])) {
31 //Validamos que los dato sno esten vacios...
32 if (empty($_POST['username']) or empty($_POST['password'])) {
//Creaos una variable de notificacion...
$_SESSION['notify'] = "<div class='alert alert-dismissible alert-danger'>The form fields are required.</div>";
header("Location: " . BASE_URL . "login/");
} elseif ($_POST['captcha'] != $_SESSION['tmptxt']) {
$_SESSION['notify'] = "<div class='alert alert-dismissible alert-danger'>The validation CAPTCHA is incorrect.</div>";
header("Location: " . BASE_URL . "login/");
} else {
//Recogemos los datos del formulario...
$user = $_POST['username'];
$pass = $_POST['password'];
$captcha = $_POST['captcha'];
$newlogin = new Validate_login();
$newlogin->validateLogin($user, $pass);
}
} else {
header("Location: " . BASE_URL . "login/");
}