<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Оформление заказа</title>
</head>
<body>
<h1>Оформление заказа</h1>
<form class="" action="saveorder.php" method="post">
<label for="">Заказчик</label>
<input type="text" name="name" id="name" value=""><br /><br />
<label for="">Email заказчика: </label>
<input type="text" name="email" id="email" value=""><br /><br />
<label for="">Телефон для связи: </label>
<input type="text" name="phone" id="phone" value=""><br /><br />
<label for="">Адрес доставки: </label>
<input type="text" name="address" id="address" value=""><br /><br />
<input type="submit" name="" value="Заказать">
</form>
</body>
</html>
require "inc/lib.inc.php";
require "inc/config.inc.php";
$name= clearStr($_POST["name"]);
$email= clearStr($_POST["email"]);
$phone= clearStr($_POST["phone"]);
$address= clearStr($_POST["address"]);
$oid = $basket["orderid"];
$dt = time();
$order = "$name|$email|$phone|$address|$oid|$dt\n";
file_put_contents("admin/".ORDERS_LOG, $order, FILE_APPEND);
saveOrder($dt);
<table border="1" cellpadding="5" cellspacing="0" width="100%">
<tr>
<th>N п/п</th>
<th>Название</th>
<th>Автор</th>
<th>Год издания</th>
<th>Цена, руб.</th>
<th>Количество</th>
<th>Удалить</th>
</tr>
<?php
$i = 1; $sum = 0;
foreach($goods as $item){
?>
<tr>
<td><?=$i++?></td>
<td><?=$item['title']?></td>
<td><?= $item['author']?></td>
<td><?= $item['pubyear']?></td>
<td><?= $item['price']?></td>
<td><?= $item['quantity']?></td>
<td><a href="delete_from_basket.php?id=<?= $item['id']?>">Удалить</a></td>
</tr>
<?
$sum += $item['price'] * $item['quantity'];
}
?>
</table>
<p>Всего товаров в корзине на сумму: <?=$sum?> руб.</p>
<div align="center">
<input type="button" value="Оформить заказ" onClick="location.href='orderform.php'"/>
</div>
</body>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Оформление заказа</title>
</head>
<body>
<h1>Оформление заказа</h1>
<form class="" action="saveorder.php" method="post">
<label for="">Заказчик</label>
<input type="text" name="name" id="name" value=""><br /><br />
<label for="">Email заказчика: </label>
<input type="text" name="email" id="email" value=""><br /><br />
<label for="">Телефон для связи: </label>
<input type="text" name="phone" id="phone" value=""><br /><br />
<label for="">Адрес доставки: </label>
<input type="text" name="address" id="address" value=""><br /><br />
<input type="submit" name="" value="Заказать">
</form>
</body>
</html>
require "inc/lib.inc.php";
require "inc/config.inc.php";
$name= clearStr($_POST["name"]);
$email= clearStr($_POST["email"]);
$phone= clearStr($_POST["phone"]);
$address= clearStr($_POST["address"]);
$oid = $basket["orderid"];
$dt = time();
$order = "$name|$email|$phone|$address|$oid|$dt\n";
file_put_contents("admin/".ORDERS_LOG, $order, FILE_APPEND);
saveOrder($dt);
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'], $item['orderid'], $datetime);
mysqli_stmt_execute($stmt);
}
mysqli_stmt_close($stmt);
removeBasket();
return true;
}