Before i start, i must clarify a few things
i’m using codeigniter 3, i know, it’s outdated but it’s for a project and i even asked "can’t we use an updated version" and i got a big "NO, it can’t run on my device" as an answer.
i know this has been asked previously by other users but none of the solution worked for me.
so here’s the problem, i got a view and a controller, the controller didn’t catch any data from the view, here’s the form code on the view
<form method="POST" action="<?php echo base_url() ?>Dashboard/tambah_matkul">
<div class="modal-body">
<div class="form-group">
<label for="exampleFormControlInput1">Nama mata kuliah</label>
<input nama="matakuliah" type="text" class="form-control" id="exampleFormControlInput4">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-primary">submit</button>
</div>
</form>
and here’s the "tambah_matkul" function on the "Dashboard" controller
public function tambah_matkul() {
$matakuliah = $this->input->post();
var_dump($matakuliah);
print_r($_POST);
}
both the "$matakuliah" and $_POST variable returns an empty array after i press the "submit" button on the view, i thought it should records what i put on the form AND pass it to the controller.
i also searched on other questions and they suggest me to modify my .htaccess file to fix it, none of them worked, so i revert it to the time before i tried any of it, heres the code for my .htaccess
RewriteEngine On
RewriteBase /pemweb2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
(i hope you guys don’t mind some of the indonesian language i used for some variable names)
2
Answers
change your attribute nama to name, input not have attribute like nama.
try post again.
Brother, you can’t use indonesian language in attributes. Eg: name, not nama