I have a form that modifies meta content of table 'wp_postmeta'. I'm trying to figure out a way to add the form results to another table (transactions).
I have the php setup and it works if I remove the "id" value from the submit input section. With ID included, the form modifies wp_postmeta but no data is sent to "transactions" table. Without ID included, the opposite. Any suggestions?
FORM Submit button:
<div class='inventory-management-form-item-holders inventory-management-submit-holder'>
<input type="submit" name="submit" value="SUBMIT" id="im-submit">
</div>
"im-submit" js SECTION:
// submit form
jQuery("#im-submit").click(function(){
// Change thw loading Gif url
jQuery('#the-results-holder').html("<img src='/wp-content/plugins/mcs-inventory-management/assets/images/loading_icon.gif' />");
jQuery.ajax({
type: "POST",
data: {'im-product-id': theProductId, 'status-quantity': jQuery('#status-quantity').val(), 'status-action': jQuery('#im-action-box').val(), 'status-location': jQuery('#status-location').val(), 'status-move-location': jQuery('#status-move-location').val()},
dataType: "json",
url: "/inventory-management-process/",
processData: true,
success: function(data) {
jQuery('#the-results-holder').html("");
jQuery('#status-stock').val(data.stock);
jQuery('#status-res').val(data.res);
jQuery('#status-prepro').val(data.prepro);
jQuery('#status-clean').val(data.clean);
jQuery('#status-quantity').val("0");
},
error: function (xhr, ajaxOptions, thrownError) {
jQuery('#the-results-holder').html("");
jQuery('#the-results-holder-error').html("There has been an error!");
}
});
return false;
});
PHP That uses INSERT Query for "transaction" table
<form name='inventory-management' id='inventory-management-form' method="POST" action='<?php $transaction ?>'>
<?php
$product= $_POST['part-number'];
$action= $_POST['status-action'];
$from_location= $_POST['status-location'];
$to_location= $_POST['status-move-location'];
$qty= $_POST['status-quantity'];
if(isset($_POST['submit']))
{
$transaction = "INSERT INTO transactions (id,product,action,from_location,to_location,qty) VALUES ('','$product','$action','$from_location','$to_location','$qty')";
$result = mysql_query($transaction);
}
?>