skip to Main Content

I have a simple question related to input post method. There are two input fields as follows :

$this->input->post('billed_date')
$this->input->post('branch_id')

Then I want to combine this two input post methods using logical "OR" argument. I used the following code :

if($this->input->post('billed_date', 'branch_id'))
{       
        .....some codes...
}

But didn’t get the desired result. How can I combine these two post methods using "OR". Can anyone help ?

2

Answers


  1. The post() method of CodeIgniter’s input library doesn’t support passing multiple keys in that way. You need to do it separately like this:

    if ($this->input->post('billed_date') && $this->input->post('branch_id'))
    {
        // ...your code here...
    }
    

    If you need it as logical OR (e.g only one variable needs to be present) you do it like this:

    if ($this->input->post('billed_date') || $this->input->post('branch_id'))
    {
        // ...your code here...
    }
    
    Login or Signup to reply.
  2. for better understand using isset function within if condition

    if (isset($this->input->post('billed_date')) || isset($this->input->post('branch_id')))
    {
        // ...your code here...
    }
    

    or you may use OR replace on || then code like below

    if (isset($this->input->post('billed_date')) OR isset($this->input->post('branch_id')))
    {
        // ...your code here...
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search