I have created 3 API queries. It starts with an autocomplete form that returns a street address and zip code. The second gets the 9 digit zipcode from USPS and the third gets the local sales tax based on the 9 digit zip, from the state. All three queries work as needed. The zip query is a php script that just returns the zip and the third is a php script that just returns the tax rate. I would like to get the second and third queries to run in sequence, and then update the current page without the user needing to do anything. Can anyone suggest my options for doing this.
What I have done so far is to use basically a next, next using session variables to pass updated information to the next page. The new page is an identical page to the first with the updated information. So I have page1.php → page2.php → page3.php. What I would like to know is, can this be done without user intervention such that the information is updated into page1.php and assuming so, what might my options be.
<?php
session_start();
$_SESSION['street_number'] = $_POST['street_number'];
$_SESSION['route'] = $_POST['route'];
$_SESSION['city'] = $_POST['city'];
$_SESSION['state'] = $_POST['state'];
$_SESSION['zip'] = $_POST['zip'];
$_SESSION['name'] = $_POST['name'];
$_SESSION['phone'] = $_POST['phone'];
$_SESSION['address'] = $_POST['street_number']." ". $_POST['route'];
?>
<?php
$street = $_SESSION['address'];
$zip = $_SESSION['zip'];
$city = $_SESSION['city'];
$state = $_SESSION['state'];
$input_xml = <<<EOXML
<AddressValidateRequest USERID="XXXXXXXXX">
<Address ID="0">
<Address1></Address1>
<Address2>$street</Address2>
<City>$city</City>
<State>$state</State>
<Zip5>$zip</Zip5>
<Zip4></Zip4>
</Address>
</AddressValidateRequest>
EOXML;
$fields = array(
'API' => 'Verify',
'XML' => $input_xml