Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Kursovaya_IP.docx
Скачиваний:
22
Добавлен:
26.03.2016
Размер:
517.89 Кб
Скачать

Order.Php

<h2 align="center">Оформление заказа</h2>

<?

if($_SESSION['cart'] && !isset($_POST['order']))

{

?>

<form action="index.php?view=order" method="post" id="cart-form">

<table id="mycart" align="center" cellspacing="0" cellpadding="0" border="0">

<tr>

<th>Товар</th>

<th>Цена</th>

<th>Кол-во</th>

<th>Всего</th>

</tr>

<? foreach($_SESSION['cart'] as $id => $quantity):

$product = get_product($id);

?>

<tr>

<td align="center"><?=$product['title'];?></td>

<td align="center"><?=number_format($product['price'],2);?></td>

<td align="center"><?=$quantity;?></td>

<td align="center"><?=number_format($product['price'] * $quantity ,2);?></td>

</tr>

<?endforeach;?>

</table>

<p class="total" align="center">Общая сумма заказа: <span class="product-price"><?=number_format($_SESSION['total_price'],2);?> </span></p>

<p align="center" style="color: #fff;">

Ваше Имя: <br />

<input type="text" name="name" /><br />

Ваша Фамилия: <br />

<input type="text" name="s_name" /><br />

Ваш адрес: <br />

<input type="text" name="address" /><br />

Почтовый индекс: <br />

<input type="text" name="post_index" /><br />

Ваш e-mail: <br />

<input type="text" name="email" /><br />

</p>

<p align="center"><input type="submit" name="order" value="Заказать" /></p>

</form>

<?

}

if($_SESSION['cart'] && isset($_POST['order']))

{

foreach($_POST as $ArrKey => $ArrStr)

{

$ArrKey = $_POST[$ArrKey];

}

$date = date('Y-m-d');

$time = date('H:i:s');

foreach($_SESSION['cart'] as $id => $quantity):

$product = get_product($id);

$query = mysql_query("INSERT INTO orders(name,s_name,address,post_index,email,date,time,product,prod_id,price,qty) VALUES ('$name','$s_name','$address','$post_index','$email','$date','$time','{$product['title']}','{$product['id']}','{$product['price']}','$quantity')");

endforeach;

echo "<p align='center' style='color: #fff;'>Ваш заказ успешно принят! Спасибо за покупку!</p>";

}

?>

Product.Php

<table align="center" cellpadding="0" cellspacing="0" class="product" border="0">

<tr>

<td valign="top">

<div><a href="#"><img src="userfiles/<?=$product['image']?>" alt="" /></a></div>

<div class="description">

<div class="product-name"><a href="#"><?=$product['title']?></a></div>

<div class="product-price">Цена: <?=$product['price']?> </div>

</div>

</td>

<table width="300px">

<tr>

<td>

<div><?=$product['description']?></div>

.</td>

</tr>

</table>

<div><a href="index.php?view=add_to_cart&id=<?=$product['id']?>">Добавить в корзину</a></div>

</td>

</tr>

</table>

Рис.15. Структура таблицы categories.

Рис.16. Структура таблицы orders.

Рис.17. Структура таблицы products.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]