Welcome Guest, Not a member yet? Register   Sign In
don't work input form in codeigniter 4
#1

i have one form below:
Code:
<form class="form-signin form-group" role="form" method="post" action="">
    <div class="login_frm">
    <div class="title_frm"><b>THÔNG TIN ĐĂNG NHẬP</b> </div>
    <div class="row">
    <div class="col-sm-6 col-md-3">
    <img src="<?php echo base_url('public/admin/images/area_09.gif'); ?>" class="img-fluid float-right" />
    </div>
    <div class="col-xs-6 col-md-9">
    <div class="form-group"><label for="exampleInputEmail1">Tên đăng nhập</label>
    <input type="text" name="email" class="form-control col-10" placeholder="Tên đăng nhập" required="" autofocus="true">
    </div>
    <div class="form-group"><label for="exampleInputPassword1">Mật khẩu</label>
    <input type="password" name="pass" class="form-control col-10" placeholder="Mật khẩu" required="">
    </div>
    </div>
    </div>
    <div class="col-xs-6 col-md-12 text-center">
    <button type="submit" class="btn btn-default btn-sm btn-primary" style="padding: 5px 25px">Đăng nhập </button>
    </div>
    </div>
</form>
my controller
PHP Code:
public function login()
        {
            if(
$this->request->getPost('email')) {
                
$username $this->request->getPost('email');
                
$pass     $this->request->getPost('pass');
                
                
redirect()->to(base_url('dasboard'));
                }
                return 
view('login');
            } 

when i click button submit, it go to file logincontroller but input email, pass dont working and go to 404 page not found

please, show me how to fix it
Reply
#2

You need to fill in the form action to tell it where to go in the controller/method.

PHP Code:
// controller/method = your controller and the method to run.
<form class="form-signin form-group" role="form" method="post" action="<?= base_url('controller/method');?>"
Try that.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(This post was last modified: 03-25-2022, 03:14 AM by ignitedcms.)

Not looked properly but forms need an action, unless you're passing that via ajax, and CRSF protection.
*Edit looks like we double posted.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply




Theme © iAndrew 2016 - Forum software by © MyBB