Jump to content
Fórum Script Brasil
  • 0

Login com CodeIgniter

Paulo Amaral


Olé estou começando com CodeIgniter, e já tenho problema no login do sistema.
Apos inserir os dados nos campos "nome" e "senha" e submeter o formulário me retorna os seguintes erros:

A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\automac\system\database\drivers\mysqli\mysqli_driver.php:221)
Filename: core/Common.php
Line Number: 569

A PHP Error was encountered
Severity: Error
Message: Maximum execution time of 60 seconds exceeded
Filename: mysqli/mysqli_driver.php
Line Number: 221

segue os códigos


	if (! defined('BASEPATH')) exit('No direct script access allowed');
	class Login_model extends CI_Model {
		//Validação do usuário		
		public function validacao($usuario, $senha){
			$this->db->where('USUARIO', $usuario);
			$this->db->where('SENHA', $senha);
			$query = $this->db->get('DBA');
			if($query->num_rows == 1){
				return true; // retorna verdadeiro
		//Verifica se usuário esta logado
		public function logado(){
			$logado = $this->session->userdata('logado');
			if(!isset($logado) || $logado != true){
				echo 'Voce nao tem permissao para entrar nessa pagina!';


	if (! defined('BASEPATH')) exit('No direct script access allowed');
	class Login extends CI_Controller{
		function __construct(){
			parent:: __construct();
		public function index(){
			$this->form_validation->set_rules('usuario', 'Usuário', 'required');
			$this->form_validation->set_rules('senha', 'Senha', 'required');
			$this->form_validation->set_error_delimiters('<p class="error">', '</p>');
			//Modelo Login
			$this->load->model('login_model', 'MLogin');
			$usuario = $this->input->post('usuario');
			$senha   = $this->input->post('senha');
			$query = $this->MLogin->validacao($usuario,$senha);
			if($this->form_validation->run() == FALSE){
				if($query){ // Verifica Login  e Senha
					$data = array(
						'usuario' =>$this->input->post('usuario'),
						'logado' => true


			<?php echo form_open();?>
				<div class="body bg-gray">
					<div class="form-group" id="loginGroup">
						<?php echo form_error('usuario', '<div class="error">', '</div>'); ?>
						<div class="input-group">
							<span class="input-group-addon"><i class="fa fa-user"></i></span>
            					echo form_input(array(
									"name" => "usuario",
									"class" => "form-control",
									"placeholder" => "Informe o Usuário"
					<div class="form-group">
						<?php echo form_error('senha', '<div class="error">', '</div>'); ?>
						<div class="input-group" id="senhaGroup">
							<span class="input-group-addon"><i class="fa fa-lock"></i></span>
								echo form_password(array(
									"name" => "senha",
									"class" => "form-control",
									"placeholder" => "Informe a Senha"
				<div class="footer bg-gray">
						echo form_submit(array(
							"name" => "submit",
							"class" => "btn bg-orange",
							"value" => "Acessar"
			<?php form_close(); ?>
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Forum Statistics

    • Total Topics
    • Total Posts
  • Create New...