trying to find the best solution. I have a form which takes two inputs: input1 and input2. I use javascript to validate these fields - as long as one of them is filled in correctly that is ok.

At the moment, I have the following PHP (removed includes)

```
if (isset($_POST["input1"]) && !empty($_POST["input1"])){
    $input1 = $_POST["input1"];
    $connection = new APIConnection1();
    $response = $connection->obtainResponse($input1);
}

if (isset($_POST["input2"]) && !empty($_POST["input2"])){
    $input2 = $_POST["input2"];
    $connection = new APIConnection2();
    $response = $connection->obtainResponse($input2);
}

```

So if input1 has data - APIConnection1 is called.
If input2 has data - APIConnection2 is called.
If both of them have valid data - both APIs are called. So each input has its own API (different). 

Here is my problem. I now have a third API, lets call it APIConnection3. If response returned for input1 is true, I need to send input1 to APIConnection3. Same applies with input2. 

Problem is, I cant really make these calls within the above if statements because it will make separate calls to APIConnection3. So I need to somehow perform the above if statements, and then get the data as a whole to send to APIConnection3.

So, if both input1 and input2 return true, I want to make one call which would be 

```
APIConnection3($input1, $input2);

```

If only one of them returns true, then it should be something like

```
APIConnection3($input1);

```

So how would I handle doing this?

Thanks