So I am using HTML and PHP to build out a form that will take in two parameters and then call an API and build out a form.
So here is the HTML:
<div class="login-page">
<div class="form">
<span>Enter the Customer Load Number and Pickup Zip Code, then click "Submit" to track your shipment.</span>
<form action="#" method="GET" style="margin-top: 20px">
<!-- <label for="reference">Customer Load Number:</label> -->
<input type="text" id="reference" name="reference" placeholder="Customer Load Number" value="<?php echo !empty($_GET['reference']) ?htmlspecialchars($_GET['reference']) :''; ?>" required="" />
<!-- <label for="zipcode">Pickup Zipcode:</label> -->
<input type="text" id="zipcode" name="zipcode" placeholder="Pickup zipcode" value="<?php echo !empty($_GET['zipcode']) ?htmlspecialchars($_GET['zipcode']) :''; ?>" required="" />
<input type="submit" name="submit" value="Submit" style="margin-top: 20px; justify-content: center" />
</form>
</div>
</div>
Then once the Customer Load Number and Zipcode are inputted and the user submits the form, it will load and execute some PHP w/ HTML output:
<?php if (isset($_GET['submit'])) {
$reference = sanitize_text_field($_GET['reference']);
$zipcode = intval($_GET['zipcode']);
$curl = curl_init();
$link = "https://example.net/customer-portal/tracking?reference=$reference&postalCode=$zipcode";
curl_setopt_array($curl, [
CURLOPT_URL => "$link",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"Reference\"\r\n\r\n2889615\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"postalCode\"\r\n\r\n35956\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--",
CURLOPT_HTTPHEADER => [
"AccountId: si",
"Authorization: Basic d2Vic-----",
"Postman-Token: 0fdfa047-----",
"cache-control: no-cache"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
$response = json_decode($response);
if ($response->Data === null) {
$message =
'<p style="text-align: center; margin-top: -50px; margin-bottom: 60px;">The provided Customer Load Number and <br/>Pickup Zipcode combination could not be validated.</p>';
echo $message;
} else {
$data = $response;
}
}
?>
The Problem:
When the user submits the form, it will build the following params and submit the form: https://example.com.test/customers/?reference=P337574&zipcode=50219&submit=Submit#
How could I have the option to have the form submit, but exclude the submit
param, so I would like the form to submit using the following params: https://example.com.test/customers/?reference=P337574&zipcode=50219
When I currently remove the submit, the form does not automatically submit.
I have tried inputting the submit
param and also removing it.