CodeIgniter Forums
CODEIGNITER 4 Post returns "error 404" - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: CODEIGNITER 4 Post returns "error 404" (/showthread.php?tid=81974)



CODEIGNITER 4 Post returns "error 404" - yasielespinosa - 05-29-2022

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'.


RE: CODEIGNITER 4 Post returns "error 404" - iRedds - 05-30-2022

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


RE: CODEIGNITER 4 Post returns "error 404" - demyr - 05-31-2022

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');