I need to send a "cart" via email and am using session
.
Basically I only need products to be sent to an email (gmail).
Thisistheshippingcode.Pleasehelpanewbie!
<?phpinclude("cabecalho.php");
?>
<?php
include("menu.php");
?>
<?php
if(isset($_POST['submit'])){
foreach($_POST['quantity'] as $key => $val) {
if($val==0) {
unset($_SESSION['cart'][$key]);
}else{
$_SESSION['cart'][$key]['quantity']=$val;
}
}
}
?>
<head>
<link rel="stylesheet" href="css/enctable.css" >
</head>
<div style="color:white ; box-shadow: 3px 3px 10px 5px #000; background: rgba(0, 0, 0, 0.7)">
<center>
<h1>Checkout</h1>
</center>
</div>
<form method="POST"
action="encomendas.php?page=cart">
<center><div>
<table align="top"><tr>
<th>Suas informações!</th></tr>
<th>Nome: <input type="text" size="35" maxlenght="256" name="nome"></th></tr>
<th>Email: <input type="text" size="35" maxlenght="256" name="email"></th></tr>
<th>CEP: <input type="text" size="35" maxlenght="256" name="cidade"></th></tr>
<th>Telefone: <input type="text" size="35" maxlenght="256" name="estado"></th>
<form action="verifica.php" method="POST">
<tr><th><button type="submit"
name="submit">Enviar!</button></th></tr>
</form>
</table>
<table cellspacing="10">
<tr>
<br>
<th>Nome </th>
<th>Quantidade </th>
<th>Valor </th>
<th>Valor do Item </th>
</tr>
<?php
if(isset($_SESSION['cart'])){
$sql="SELECT * FROM products WHERE id_product IN (";
foreach($_SESSION['cart'] as $id => $value) {
$sql.=$id.",";
}
$sql=substr($sql, 0, -1).") ORDER BY name ASC";
$query=mysql_query($sql);
$totalprice=0;
while($row=mysql_fetch_array($query)){
$subtotal=$_SESSION['cart'][$row['id_product']]['quantity']*$row['price'];
$totalprice+=$subtotal;
?>
<tr>
<td><?php echo $row['name'] ?> </td>
<td><input name="quantity[<?php echo $row['id_product'] ?>]" size="5" value="<?php echo $_SESSION['cart'][$row['id_product']]['quantity'] ?>" /></td>
<td><?php echo $row['price'] ?>R$</td>
<td><?php echo $_SESSION['cart'][$row['id_product']]['quantity']*$row['price'] ?><font size="6"> R$</td>
<?php
}
?>
<tr><th colspan="4">
<p>Valor total: <?php echo $totalprice ?><font size="5"> R$</></p></th><tr>
<?php
}
else {
$redirect = "http://localhost/Padaria23/zerado.php";
header("location:$redirect");
}
?>
</table>