Welcome Guest, Not a member yet? Register   Sign In
Form action not working
#1

(This post was last modified: 05-29-2021, 11:54 AM by Secux.)

This is the code. When you press the submit button, nothing happens

view:
Code:
<form  method="post" action="<?php echo subSECURE;?>/index.php/User/add" autocomplete="off" enctype="multipart/form-data">
<input type="text" name="username" class="form-control" placeholder="" >
<button type="submit" class="btn btn-primary"><?= lang('Core.Dash.Add') ?></button>
</form>

Routes:
PHP Code:
$routes->post('User/add/(:segment)''User::add/$1',['filter' => 'auth']); 


Controllers:
PHP Code:
class User extends BaseController
{
    .... 
    public function add(){

 if (
$this->request->getMethod() == 'post') {

 
// SET UP RULES
 
$rules = [
 
'username' => [
                    'rules' => 'required',
                    'errors' => [
 
'required' => lang('Core.Auth.Error.required')
                    ]
                ],
 ];

 
// VALIDATE RULES
 
if (!$this->validate($rules)) {
                // isError
 
$data['validation'] = $this->validator;
 } else {

 
// isOK
 
return redirect()->to(subSECURE .'/users');
 }
 }


 }
    ... 
Reply


Messages In This Thread
Form action not working - by Secux - 05-29-2021, 11:50 AM
RE: Form action not working - by includebeer - 05-29-2021, 12:30 PM
RE: Form action not working - by Secux - 05-29-2021, 01:00 PM
RE: Form action not working - by includebeer - 05-29-2021, 01:19 PM
RE: Form action not working - by Secux - 05-29-2021, 01:43 PM



Theme © iAndrew 2016 - Forum software by © MyBB