php - CodeIgniter's form action is not working properly -


i have failed many times figure out why action attribute of form malfunctioning when click submit button.

all wanted pass form data controller. what's happening browser redirecting me page (on localhost, uri correctly supplied.)

<form name = "employee" method = "post" action = "<?php echo base_url() .'employee/add_employee'; ?>"> first name:  <input type = "text" name = "f_name"> middle name: <input type = "text" name = "m_name"> last name:   <input type = "text" name = "l_name"> <input type = "submit" value = "save"> </form> 

here's add_employee function in employee.php (with class name of 'employee'):

public function add_employee(){      $employee = array(     'f_name' => $this->input->post('f_name'),     'm_name' => $this->input->post('m_name'),     'l_name' => $this->input->post('l_name')     );      $this->employee_model->insert_employee($employee);      echo "employee added!<br />"; } 

i don't think employee_model problem, won't add here. i'm guessing problem has url in form action.

why browser redirecting me page instead of executing add_employee() function?

so after long discussion, here solution :

in htaccess, had change

rewritebase /ci/ rewritebase /ci_practice2

also, maybe have mamp (maybe not)

localhost:8080/ci_practice2

it's if didn't change defaults ports of mamp.

have nice day


Comments