Codeigniter controller cannot get POST data from view
P粉713846879
P粉713846879 2023-09-03 11:34:13
0
1
587
<p>Before I begin, I must clarify something I'm using codeigniter 3 and I know, it's outdated but it was for a project and I even asked "can't we use a newer version" and I got a big "no it can't be used on my running on the device" was the answer. I know other users have asked this question before, but none of the solutions worked for me. </p> <p>So here comes the problem, I have a view and a controller, the controller is not capturing any data from the view, here is the form code on the view</p> <pre class="brush:php;toolbar:false;"><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></pre> <p>This is the 'tambah_matkul' function on the 'Dashboard' controller</p> <pre class="brush:php;toolbar:false;">public function tambah_matkul() { $matakuliah = $this->input->post(); var_dump($matakuliah); print_r($_POST); }</pre> <p>After I press the "Submit" button on the view, both the "$matakuliah" and $_POST variables return an empty array, which I thought was supposed to record what I put on the form and pass it to the controller ​​. </p> <p>I also searched for other questions and they suggested me to modify my .htaccess file to fix it but none of them worked so I reverted it to the time before I tried any of them and here is my .htaccess Code< /p> <pre class="brush:php;toolbar:false;">RewriteEngine On RewriteBase /pemweb2 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L]</pre> <p>(I hope you don’t mind if I use some Indonesian for variable names)</p>
P粉713846879
P粉713846879

reply all(1)
P粉930448030

Change your attribute nama to name, the input has no attribute like nama.

<input name="matakuliah" type="text" class="form-control" id="exampleFormControlInput4">

Try posting again.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template