I posted two javascript variables to a php file aswell as a html form using Ajax separately. I want to use the two javascript variables with the posted form values but I'm not sure how to go about this.

```js
<script>
   $(document).ready(function() {
      var aucid = "<?php echo $auctionID; ?>";
      var userid = "<?php echo $userID; ?>";
  $.ajax({
    url: "JqueryPHP/HighestBid.php",
    method: "POST",
    data: {'auctionid': aucid, 'userid' : userid },
    success: function (result) {
        $('#price').html(result);
    }
});

  $('form').bind('submit', function (event) {

event.preventDefault();// using this page stop being refreshing 

          $.ajax({
           type: 'POST',
            url: 'JqueryPHP/HighestBid.php',
            data: $('form').serialize(),
            success: function () {
              alert('form was submitted');
            }
          });

        });

  });
```

I posted the two javascript variables separately to the form.

```html
<form> 

<input type="number" min="<?php echo $startingprice ?>" step="any" style="width: 10em;" size="35" name="newbid" id="newbid" tabindex="1" class="form-control"  placeholder="New Bid €" value="" required>
 <input type="submit" name="submit" id="submit" tabindex="2" class="form-control btn btn-login" style="width: 14em" value="submit">

 </form>
```

```html
<h4 class="price">Highest bid : <span id="price"></span></h4>
```

When I echo the value of userID into the span class, you can see it has a value of 2.

[![enter image description here](https://i.stack.imgur.com/mD28l.png)](https://i.stack.imgur.com/mD28l.png)

```html
//JqueryPHP/HighestBid.php'

$auctionid;
$userID;

  $auctionid = $_POST['auctionid'];
  $userID = $_POST['userid'];
  echo $userID;

  if (isset($_POST['newbid'])) 
  {
  $newbid=$_POST['newbid'];

    $conn = new mysqli('localhost', 'root', '', 'auctionsite');
 $sql = 'INSERT INTO auction (useridhighestbid)VALUES("'.$userID.'")';
 if(@$conn->query($sql)){  //execute the query and check it worked    
                            return TRUE;
                        } 

  }
```

however when I try use the userID when the form is submitted and try insert it into the database for testing purposes, the value is 0.

How would I go about posting the form value with the javascript variables so I can use an update statement to update my database?

[![enter image description here](https://i.stack.imgur.com/eavTe.png)](https://i.stack.imgur.com/eavTe.png)