Good night here staff Brazil,
I'm trying to validate an e-mail and password field, that future will come from the global $ _POST, but I'm porenquanto testing the class I am creating.
Even I already sending a completed array with the data to validate, validation returns me errors that do not exist.
Follows the code of my MODEL (m_login.php):
Follows the code of my CONTROLLER (login.php):
This is what my CONTROLLER (login.php) is displaying on the screen, I realize that even through e-mail and password validation says the fields are empty (the screen print is attached to this post).
validation_print.png (Size: 46.92 KB / Downloads: 7)
I'm trying to validate an e-mail and password field, that future will come from the global $ _POST, but I'm porenquanto testing the class I am creating.
Even I already sending a completed array with the data to validate, validation returns me errors that do not exist.
Follows the code of my MODEL (m_login.php):
PHP Code:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* @category Model
* @tutorial Model responsável por CRIAR, EDITAR, EXCLUIR e LISTAR os USUÁRIOS
* dentro do PAINEL ADMIN do sistema.
*/
class M_login extends CI_Model {
private $Level;
private $Data;
private $Error;
private $Result;
private $Table = "ws_users";
//PUBLIC METHODS
public function ExeLogin($data) {
$this->setData($data);
$this->validateData();
}
public function getUser() {
$where = array("user_email" => $this->getData()['user_email'], "user_password" => $this->getData()['user_password']);
$this->db->where($where);
$getUser = $this->db->get($this->Table)->result_array()[0];
return $getUser;
}
function getData() {
return
$this->Data;
}
function getError() {
return
$this->Error;
}
function getResult() {
return
$this->Result;
}
//PRIVATE METHODS
private function setData($data) {
$getData = array_map("strip_tags", $data);
$this->Data = array_map("trim", $getData);
}
private function validateData() {
$this->form_validation->set_data($this->Data);
$this->form_validation->set_rules("user_email ", "Email ", "trim|required|valid_email");
$this->form_validation->set_rules("user_password ", "Senha ", "trim|required|min_length[6]|max_length[10]");
if ($this->form_validation->run()):
$this->Error = "Campos validados com sucesso!";
$this->Result = true;
else:
$this->Error = $this->form_validation->error_array();
$this->Result = false;
endif;
return $this->Result;
}
}
?>
Follows the code of my CONTROLLER (login.php):
PHP Code:
/**
* Controller responsável por decidir as ações a serem tomadas
* para com relação ao login dos usuários dentro do PAINEL ADMIN
*/
class login extends CI_Controller {
public function index() {
//Chama as views e passa como parâmetro os dados para serem listados:
$this->load->view("dashboard/includes/v_header");
$this->load->view("dashboard/autenticacao/v_form-login");
$this->load->view("dashboard/includes/v_footer");
$data["user_email"] = "dcdouglas64@gmail.com";
$data["user_password"] = "123456";
$this->m_login->ExeLogin($data);
var_dump($this->m_login);
}
}
?>
This is what my CONTROLLER (login.php) is displaying on the screen, I realize that even through e-mail and password validation says the fields are empty (the screen print is attached to this post).
