[eluser]Unknown[/eluser]
Hello,
I am brand spankin' new to PHP/CI and I am struggling to get the value from a dropdown box in a form. I can get a numeric value but I need the text value so that I can save it to my database which expects a text enum.
I pass this array to my view
$data['location_enums'] = array('UK', 'US', 'Brazil', 'India', 'China');
In my view I display the dropdown box with...
<p>
<label for="location">Location:</label>
<?php echo form_dropdown('location', $location_enums, 'UK'); ?>
</p>
My controller calls add_user() in my model if the entire form passes validation. The add_user() method is as follows...
public function add_user($location, $role)
{
$data=array (
'name'=>$this->input->post('username'),
'password'=> md5($this->input->post('password')),
'location'=> $this->input->post('location'),
'role'=> $this->input->post('role'),
'email'=>$this->input->post('email')
);
$this->db->insert('Users',$data);
From what I can gather $this->input->post('location') returns a numeric value and not the text value that the user has selected but it's the text value I need. Any ideas?
Thank you.