php - submit form to MySQL database, working only once -
i have problem sending data table, table supposed keep placed order
, cart_array
, name
, first name
, last name
, etc..
it submits, first time, , if want place order nothing happens... won't send data table.
if delete first entry table , place order again, works auto increment id jumps 1 deleted(let's id-1 id-14, depends on mow many attempts i've had)
the php block is
<?php function register_transaction($register_order){ array_walk($register_order, 'array_sanitize'); $fields = '`' . implode('`, `', array_keys($register_order)) . '`'; $data = '\'' . implode('\', \'', $register_order) . '\''; mysql_query("insert `transactions` ($fields) values ($data)"); } if (empty($_post) === false) { $register_order = array( 'product_id_array' => $_post['product_id_array'], 'payer_email' => $_post['payer_email'], 'first_name' => $_post['first_name'] ); register_transaction($register_order); } ?>
form
<form action="" method="post"> <ul style="position:relative"> <li style="float:none;">cart<br /> <input type="text" name="product_id_array" value="<?php echo $product_id_array;?>" /></li> <li style="float:none;">email<br /> <input type="email" name="payer_email" value="<?php echo $user_data["email"];?>" /></li> <li style="float:none;">name<br /> <input type="text" name="first_name" value="<?php echo $user_data["name"];?>" /></li> <li style="float:none;"> <input type="submit" value="trimite comanda" /></li> </ul> </form>
fixed... there unique field in database table.. wasn't sending data , remained blank after first submit, , because unique, couldn't blank again..
Comments
Post a Comment