Welcome Guest, Not a member yet? Register   Sign In
Error 404 xampp
#1

[eluser]Thiago Leao[/eluser]
when I try to login, it throws me to a page 404 is that it exists

But, my main page works!
localhost/mywebsite/admin - OK

index.php

Code:
<?php
         echo validation_errors();
   $attributes = array('name' => 'form', 'class' => 'mainForm');
   echo form_open(base_url().'admin/home/login', $attributes);
  ?>
            <fieldset>
                <div class="loginRow noborder">
                    <label for="req1">Usuário:</label>
                    <div class="loginInput">&lt;? echo form_input('login', set_value('login')); ?&gt;</div>
                    <div class="fix"></div>
                </div>
                
                <div class="loginRow">
                    <label for="req2">Senha:</label>
                    <div class="loginInput">&lt;? echo form_password('senha', set_value('senha')); ?&gt;</div>
                    <div class="fix"></div>
                </div>
                
                <div class="loginRow">
                    &lt;input type="submit" value="Entrar" class="greyishBtn submitForm" /&gt;
                    <div class="fix"></div>
                </div>
            </fieldset>
        &lt;? echo form_close(); ?&gt;


home.php (Controller)

Code:
&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller{
  
  public function index(){  
   $dados['titulo'] = 'Vai de Brasil - Administração!';
   $this->load->view('admin/index', $dados);
  }
  
  public function login(){
  
   $this->load->library('form_validation');
   $config = array(
   array('field'=>'login', 'label'=>'Login'),
   array('field'=>'senha', 'label'=>'Senha', 'rules' => 'required| min_length[4]| max_length[12]| htmlspecialchars')
   );
  
   $this->form_validation->set_rules($config);
   if($this->form_validation->run() == FALSE){
    $this->index();    
   }
   else{
    $data['login'] = $this->input->post('login');
    $data['senha'] = $this->input->post('senha');
    $this->load->model('admin/usuarios_model');
    $login = $this->usuarios_model->validaUsuario($data);
    
    if(count($login)>0){
     $this->load->library('session');    
     $newdata = array('nome' => $login[0]->nome, 'id_user' => $login[0]->id_user, 'login' => $data['login'], 'loggedin' => TRUE);
     $this->session->set_userdata($newdata);
     redirect(base_url().'[b]admin/logado[/b]', 'refresh');
    }else{
     $this->index();
    }
   }
  }
  
}
?&gt;

he had to throw me logado.php but the error 404

why?
thanks!


thanks!
#2

[eluser]Thiago Leao[/eluser]
anyone?
thanks guys!
#3

[eluser]Beginers[/eluser]
Code:
echo form_open(base_url().'admin/home/login', $attributes);

change to

Code:
echo form_open('home/login', $attributes);

since Admin is not your controller name. Home is your controller and login is your function name;




Theme © iAndrew 2016 - Forum software by © MyBB