I have a simple form.. where users will input data, and I want that data to be sent to the server upon clicking on save.
This is my form:
<form method="POST" name="admin_form" action=" ">
                    <div class="form-row">
                        <div class="form-group col-md-12">
                            <label for="inputEmail4">Product Name</label>
                            <input type="name" class="form-control" name="name" id="inputproductname"
                                placeholder="Product name">
                        </div>
                        <div class="form-group col-md-12">
                            <label for="inputPassword4">Description</label>
                            <textarea class="form-control" name="description" id="exampleFormControlTextarea1"
                                rows="3"></textarea>
                        </div>
                    </div>
                    <!-- start select shop -->
                    <div class="form-group">
                        <label for="exampleFormControlSelect2">Select shop</label>
                        <?php 
                $q = "SELECT * FROM heroku_50fc799819d.shops ORDER BY  name ASC";        
                $r = mysqli_query($conn,$q);
                    ?>
                        <select class="form-control" name="shops" id="shops" required>
                            <!-- <option value="0">Select category.</option> -->
                            <?php while ($data = mysqli_fetch_array($r)){
                $id = $data['id'];
                $name = $data['name']; 
                ?>
                            <option value="<?php echo $id;?>"> <?php echo $name; ?> </option>
                            <?php } ?>
                        </select>
                    </div>
                    <!-- end shop select -->
                    <!-- image select -->
                    <form>
                        <div class="form-group">
                            <label for="exampleFormControlFile1">Upload image product</label>
                            <input type="file" class="form-control-file" id="exampleFormControlFile1">
                        </div>
                    </form>
                    <!-- end image select -->
                    <!-- start category select -->
                    <div class="form-group">
                        <label for="exampleFormControlSelect1">Select one or multiple categories</label>
                        <?php 
                $q = "SELECT * FROM heroku_50fc799819d.categories ORDER BY  name ASC";        
                $r = mysqli_query($conn,$q);
                    ?>
                        <select multiple class="form-control" name="category" id="product_category" required>
                            <!-- <option value="0">Select category.</option> -->
                            <?php while ($data = mysqli_fetch_array($r)){
                $id = $data['id'];
                $name = $data['name']; 
                ?>
                            <option value="<?php echo $id;?>"> <?php echo $name; ?> </option>
                            <?php } ?>
                        </select>
                    </div>
                    <!-- end category select -->
                    <div class="form-group">
                        <label for="inputPrice">Price</label>
                        <input type="text" class="form-control" name="price" id="inputPrice" placeholder="12000">
                    </div>
                    <div class="form-group">
                        <label for="inputPrice">Discount</label>
                        <input type="text" class="form-control" name="discount" id="inputPrice" placeholder="10">
                    </div>
                    <div class="form-group">
                        <label for="inputPrice">Qty</label>
                        <input type="text" class="form-control" name="qty" id="inputPrice" placeholder="10">
                    </div>
                    <button type="submit" name="submit" class="btn btn-primary">
                        Save
                    </button>
                </form>
and this is how am trying to send the data:
$post_data = new \stdClass();
$final_post_data = new \stdClass();
$post_data ->name = $_POST['name']?? '';
$post_data ->description = $_POST['description']?? '';
$post_data ->shopId = $_POST['shops']?? '';
$post_data ->categories = [2, 16, 278];
$post_data ->price = $_POST['price']?? '';
$post_data ->quantity = $_POST['qty']?? '';
$post_dataJSON = json_encode($post_data);
$final_post_data ->body = $post_dataJSON;
$final_post_dataJSON = json_encode($final_post_data);
//initialize
$ch = curl_init('https://admin2go.herokuapp.com/api/admin/products/create');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
//adding the post variable to the request
curl_setopt($ch, CURLOPT_POSTFIELDS, $final_post_dataJSON);
//Return output instead of outputting it
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
    'Content-Type: application/json',                                                                                
    'Content-Length: ' . strlen($final_post_dataJSON)
    )                                                                       
);  
$result = curl_exec($ch);
if ($result === FALSE) {
    echo "cURL Error: " . curl_error($ch);
}
//close and free up the curl handle
curl_close($ch);
//Display row output
print_r($result);
?>
i am currently getting this error message back from the server. so how do i pass the data from the form over by clicking on save?? {"error":"No product name passed"}
 
    