php - Sending serialized form to database -


i'm trying send serialized form database. i'm doing because each form can have different number of user-created input fields , wanted simple way store forms same way. question when serialize form, use jquery attach hidden input field, , send the form , other information database, rest of information reaching database still have blank in serialized form is. if point out went wrong and/or explain how should done i'd grateful! thank much!

here how i'm sending data database:

$orderdate = mysql_prep($_post["orderdate"]);         $ordername = mysql_prep($_post["ordername"]);         $formserialized = mysql_prep($_post["formserialized"]);           $query = "insert test (orderdate, ordername, orderserialized) values ('{$orderdate}', '{$ordername}', '{$orderserialized}')";         $result = mysqli_query($connection, $query);     

here hidden field trying attach serialized form to:

<input type="hidden" id="phpvar" name="phpvar" value="<?php echo $var; ?>"> 

and here jquery:

var formserialized = $("form").serialize(); $("#phpval").val(formserialized); 

it looks serializing form , insert element id of phpval.

you should use jquery ajax function send serialized form , post php page. ref. http://api.jquery.com/jquery.ajax/

$('#submit').click(function(){     var form = $('#my_awesome_form');      $.ajax( {       type: "post",       url: form.attr( 'action' ),       data: form.serialize(),       success: function( response ) {         console.log( response );       }     }); }); 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -