Есть такой код страницы корзины. Как подправить содержимое письма чтобы данные отображались корректно? На мыло при отправке какая-то чухня приходит))
<?php
if(isset($_POST['submit'])){
foreach($_POST['quanity'] as $key => $val) {
if($val==0) {
unset($_SESSION['cart'][$key]);
}else{
$_SESSION['cart'][$key]['quanity']=$val;
}
}
}
?>
<h1>View Cart</h1>
<a href="index.php?page=products">Go back to products page</a>
<form method="post" name="tab" action="index.php?page=cart">
<table>
<tr>
<th>Name</th>
<th>Quanity</th>
<th>Price</th>
<th>Items Price</th>
</tr>
<?php
require("includes/connection.php");
$connect = mysqli_connect($server, $user, $password, $db);
$sql="SELECT * FROM products WHERE id IN(";
foreach($_SESSION['cart'] as $id => $value) {
$sql.=$id.",";
}
$sql=substr($sql, 0, -1).") ORDER BY name ASC";
$query=mysqli_query($connect, $sql);
$totalprice=0;
while($row=mysqli_fetch_array($query)){
$subtotal=$_SESSION['cart'][$row['id']]['quanity']*$row['price'];
$totalprice+=$subtotal;
?>
<tr>
<td><?php echo $row['name'] ?></td>
<td><input type="text" name="quanity[<?php echo $row['id'] ?>]" size="5" value="<?php echo $_SESSION['cart'][$row['id']]['quanity'] ?>" /></td>
<td><?php echo $row['price'] ?>$</td>
<td><?php echo $_SESSION['cart'][$row['id']]['quanity']*$row['price'] ?>$</td>
</tr>
<?php
}
?>
<tr>
<td colspan="4">Total Price: <?php echo $totalprice ?></td>
</tr>
</table>
<br/>
<button type="submit" name="submit">Update Cart</button>
<input type="text" name="fio" placeholder="Укажите ФИО">
<input type="text" name="email" placeholder="Укажите e-mail">
<button type="submit" name="order">Отправить</button>
</form>
<?php
require("includes/connection.php");
$connect = mysqli_connect($server, $user, $password, $db);
$sql="SELECT * FROM products WHERE id IN(";
foreach($_SESSION['cart'] as $id => $value) {
$sql.=$id.",";
}
$sql=substr($sql, 0, -1).") ORDER BY name ASC";
$query=mysqli_query($connect, $sql);
$totalprice=0;
while($row=mysqli_fetch_array($query)){
$subtotal=$_SESSION['cart'][$row['id']]['quanity']*$row['price'];
$totalprice+=$subtotal;
if(isset($_POST['order'])){
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'From: Your name <[email protected]>' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$content='
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<tr>
<td>' .$row["name"]. '</td>
<td><input type="text" name="quanity[' .$row["id"]. ']" size="5" value="' .$_SESSION["cart"][$row["id"]]["quanity"]. '" /></td>
<td>' .$row["price"]. '$</td>
<td>' .$_SESSION["cart"][$row["id"]]["quanity"]*$row["price"]. '$</td>
</tr>
</body>
</html>
';
$message = $_POST['fio'].$content;
$message = wordwrap($message, 70, "\r\n");
mail($_POST['email'], 'My Subject', $message, $headers);
echo "<script type='text/javascript'>alert('$content');</script>";
}
?>
<br />
<p>To remove an item, set it's quanity to 0. </p>