<?php
// Check if form is submitted
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['submit'])) {

    // Prepare the data for the API call
    $data = array(
        'name' => $_POST['name'],
        'email' => $_POST['email'],
        'phone' => $_POST['phone']
    );

    // Send the API request
    $response = wp_remote_post('https://delivery.mailzip.ng/api/rider/create', array(
        'headers' => array('Content-Type' => 'application/json'),
        'body' => json_encode($data),
        'timeout' => 30
    ));

    // Check for errors in the API response
    if (is_wp_error($response)) {
        echo "Error: " . $response->get_error_message();
    } else {
        // Display the API response
        $response_body = json_decode(wp_remote_retrieve_body($response), true);
        echo "API Response: " . $response_body['message'];
    }
}
?>

<!-- Display the form -->
<form method="post">
    <label for="name">Name:</label>
    <input type="text" name="name" required>

    <label for="email">Email:</label>
    <input type="email" name="email" required>

    <label for="phone">Phone:</label>
    <input type="text" name="phone" required>

    <button type="submit" name="submit">Submit</button>
</form>