Welcome Guest, Not a member yet? Register   Sign In
CODEIGNITER 4 Post returns "error 404"
#1

I'm trying to use a post method in a form, but returns "error 404".

If anyone know what is happening please help me. Thanks


HTML:

PHP Code:
<form action="<?= site_url('auth/save'); ?>" method="post" enctype="multipart/form-data" class="user"
CONTROLLER:

PHP Code:
public function save(){
    // Validando la solicitud

    $validation $this->validate([
        'name'=>'required',
        'email'=>'required|valid_email|is_unique(users.email)',
        'password'=>'required|min_length[5]|max_length[12]',
        'cpassword'=>'required|min_length[5]|max_length[12]|matches[password]'
    ]);
    if (!$validation){
        $page_name 'Registrarse';
        //return view('auth/offline_header',array('page_name' => $page_name)).view('auth/register',['validation'=>$this->validator]).view('auth/offline_footer');
        return view('auth/register',['validation'=>$this->validator]);
    }else{
        echo 'Form validated successfully';
    }




ERROR:

Can't find a route for 'auth/save'.
Reply
#2

Wrong route or class name, or not enough data to identify the problem.
Reply
#3

Since auto routing is disabled you need to write your routing line for your post processes as well:

PHP Code:
$routes->post('YourController/your_method''YourController::your_method'); 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB