if isset _POST name isset _POST email isset _POST phone isset _POST ad

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
if(isset($_POST['name']) && isset($_POST['email']) && isset($_POST['phone']) && isset($_POST['address'])){
$order = $_POST['name']."|".$_POST['email']."|".$_POST['phone']."|".$_POST['address']."|".$basket['orderid']."|".time()."\n";
file_put_contents('admin/'.ORDER_LOG, $order, FILE_APPEND);
saveOrder(time());
}
function saveOrder($datetime){
global $link, $basket;
$goods = myBasket();
$stmt = mysqli_stmt_init($link);
$sql = 'INSERT INTO orders (title, author, pubyear, price, quantity, orderid, datetime) VALUES (?, ?, ?, ?, ?, ?, ?)';
if (!mysqli_stmt_prepare($stmt, $sql)) return false;
foreach($goods as $item){
mysqli_stmt_bind_param($stmt, "ssiiisi", $item['title'], $item['author'], $item['pubyear'], $item['price'], $item['quantity'], $basket['orderid'], $datetime);
mysqli_stmt_execute($stmt);
}
mysqli_stmt_close($stmt);
setcookie('basket', '', 1000);
return true;
}