我想通过电子邮件发送购物车,但是我不能...请帮助,谢谢。
我不知道该怎么做,我已经尝试了很多选择,但是没有一个选择
<?php
$namebusiness = $_POST['namebusiness'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$adress = $_POST['adress'];
$city = $_POST['city'];
$psc = $_POST['psc'];
$state = $_POST['state'];
$phone = $_POST['phone'];
$visitor_email = $_POST['email'];
$data = $_POST['data'];
$email_subject = "Order";
$message = "
<html>
<head>
<title>Your order</title>
</head>
<body>
<table>
<tr>
<th>Name Of Business:</th>
<td>$namebusiness</td>
</tr>
<tr>
<th>First name</th>
<td>$firstname</td>
</tr>
<tr>
<th>Last name:</th>
<td>$lastname</td>
</tr>
<tr>
<th>E-mail:</th>
<td>$visitor_email</td>
</tr>
<tr>
<th>Adress:</th>
<td>$adress</td>
</tr>
<tr>
<th>City:</th>
<td>$city</td>
</tr>
<tr>
<th>Post Code / ZIP:</th>
<td>$psc</td>
</tr>
<tr>
<th>State:</th>
<td>$state</td>
</tr>
<tr>
<th>Phone number:</th>
<td>$phone</td>
</tr>
<tr>
<th>Product Name</th>
<th>Quantity</th>
<th>Price</th>
<th>Total</th>
</tr>
</table>
</body>
</html>
";
$to = "$visitor_email, patrikl123@seznam.cz";
$headers = 'From: Czech@HouseITD.com' . "\r\n" .
'Content-type: text/html; charset=UTF-8' . "\r\n".
'X-Mailer: PHP/' . phpversion();
mail($to,$email_subject,$message,$headers);
header("Content-type: text/html; charset=UTF-8");
header("Location: thanks.html");
?>
<?php
//index.php
?>
<!DOCTYPE html>
<html>
<head>
<script src="js/jquery.min.js"></script>
<meta charset="UTF-8">
<link rel="stylesheet" href="style1.css">
<link rel="stylesheet" href="css/bootstrap.min.css" />
<title>Czech House ITD</title>
<script src="js/bootstrap.min.js"></script>
<div id="navbar-cart" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a id="cart-popover" class="btn" data-placement="bottom" title="Shopping Cart">
<span class="glyphicon glyphicon-shopping-cart"></span>
<span class="badge"></span>
<span class="total_price">£ 0.00</span>
</a>
</li>
</ul>
</div>
</div>
</nav>
<form id="concact-form" method="post" action="concact-form.php">
<div id="popover_content_wrapper" style="display: none">
<span id="cart_details"></span>
<div align="right">
<a href="concact.php" class="btn btn-primary" id="check_out_cart">
<span class="but"></span>Send
</a>
<a href="#" class="btn btn-default" id="clear_cart">
<span class="glyphicon glyphicon-trash"></span> Clear
</a>
</div>
</div>
</form>
<div id="display_item">
</div>
</div>
<br />
<div class="footer1">
<h7 class="footer2">Copyright © 2018 Patrik Schiller </h7>
</div>
</body>
</html>
$(document).ready(function() {
load_product();
load_cart_data();
function load_product() {
$.ajax({
url: "fetch_itemtoys.php",
type: "POST",
success: function(data) {
$('#display_item').html(data);
}
});
}
function load_cart_data() {
$.ajax({
url: "fetch_carttoys.php",
method: "POST",
dataType: "json",
success: function(data) {
$('#cart_details').html(data.cart_details);
$('.total_price').text(data.total_price);
$('.badge').text(data.total_item);
}
});
}
$('#cart-popover').popover({
html: true,
container: 'body',
content: function() {
return $('#popover_content_wrapper').html();
}
});
$(document).on('click', '.add_to_cart', function() {
var product_id = $(this).attr("id");
var product_name = $('#name' + product_id + '').val();
var product_price = $('#price' + product_id + '').val();
var product_quantity = $('#quantity' + product_id).val();
var action = "add";
if (product_quantity > 0) {
$.ajax({
url: "actiontoys.php",
method: "POST",
data: {
product_id: product_id,
product_name: product_name,
product_price: product_price,
product_quantity: product_quantity,
action: action
},
success: function(data) {
load_cart_data();
alert("Item has been Added into Cart");
}
});
} else {
alert("lease Enter Number of Quantity");
}
});
$(document).on('click', '.delete', function() {
var product_id = $(this).attr("id");
var action = 'remove';
if (confirm("Are you sure you want to remove this product?")) {
$.ajax({
url: "actiontoys.php",
method: "POST",
data: {
product_id: product_id,
action: action
},
success: function() {
load_cart_data();
$('#cart-popover').popover('hide');
alert("Item has been removed from Cart");
}
})
} else {
return false;
}
});
$(document).on('click', '#clear_cart', function() {
var action = 'empty';
$.ajax({
url: "actiontoys.php",
method: "POST",
data: {
action: action
},
success: function() {
load_cart_data();
$('#cart-popover').popover('hide');
alert("Your Cart has been clear");
}
});
});
});
谢谢您的帮助
答案 0 :(得分:0)
只需添加MIME版本:
$headers = 'From: Czech@HouseITD.com' . "\r\n" .
"MIME-Version: 1.0" . "\r\n" .
'Content-type: text/html; charset=UTF-8' . "\r\n".
'X-Mailer: PHP/' . phpversion();
通过在这里没有任何串联的方式,您可以编写:
$headers = 'From: Czech@HouseITD.com \r\n' .
'MIME-Version: 1.0 \r\n' .
'Content-type: text/html; charset=UTF-8 \r\n'.
'X-Mailer: PHP/' . phpversion();