I have a problem with sending data to a table,
the table is supposed to keep all placed order
, cart_array
, name
, first name
, last name
, etc..
It submits, first time, and then if I want to place another order nothing happens... it won't send the data to the table.
If i delete the first entry from the table and place the order again, it works but the Auto Increment ID jumps from the one I just deleted(let's say from id-1 to 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 INTO `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>