I'm trying to send a serialized form to my database. I'm doing this because each form can have a different number of user-created input fields and wanted a simple way to store all the forms the same way. My question is that when I serialize the form, use JQuery to attach it to a hidden input field, and then send the the form and some other information to the database, the rest of the information is reaching the database but I still have a blank in where the serialized form is. If anyone could point out where I went wrong and/or explain how this should be done I'd be very grateful! Thank you very much!
Here is how I'm sending the data to the database:
$orderDate = mysql_prep($_POST["orderDate"]);
$orderName = mysql_prep($_POST["orderName"]);
$formSerialized = mysql_prep($_POST["formSerialized"]);
$query = "INSERT INTO test (orderDate, orderName, orderSerialized) VALUES ('{$orderDate}', '{$orderName}', '{$orderSerialized}')";
$result = mysqli_query($connection, $query);
Here is the hidden field I am trying to attach the serialized form to:
<input type="hidden" id="phpVar" name="phpVar" value="<?php echo $var; ?>">
And here is the JQuery:
var formSerialized = $("form").serialize();
$("#phpval").val(formSerialized);