Codeigniter: getting select option from form
Ensure your html looks like:
<form action="<?= site_url('mycontroller/myfunction');?>" method='post'> <input type='text' name='ionum'/> <select name='thisdb'> <option value='db1'>DB1</option> <option value='db2'>DB2</option> </select></form>
Then in your controller, you would write:
class Mycontroller extends CI_Controller{ function myfunction(){ $p = $this->input->post(); if($p){ //you can now access the ionum and thisdb... try echo echo $p['ionum']; echo $p['thisdb']; } }}
It is unnecessary to run the if($_SERVER['REQUEST_METHOD'] == "POST")
conditional. Just check if $p
exists as above.