i want to put two button in my view.and two button send value to one controller. how to check which button press?! according this link Link
but in controller not get value of button.any idea?
i want to put two button in my view.and two button send value to one controller. how to check which button press?! according this link Link
but in controller not get value of button.any idea?
Use the same approach, however in CodeIgniter your code will look a bit clearer :
<form action="TheController/PostHandler" method="POST">
<input type="submit" name="button1" id="button1" value="Button 1" />
<input type="submit" name="button2" id="button2" value="Button 2" />
</form>
Because in CodeIgniter, this is :
$something = $this->input->post('something');
equivalent to :
$something = isset($_POST['something']) ? $_POST['something'] : NULL;
Simply check for null values with a code like this :
public function PostHandler(){
if (!is_null($this->input->post('button1'))){
// code for button 1
}
if (!is_null($this->input->post('button2'))){
// code for button 2
}
}