我已经推出了我的网站。我试图使用PHP在电子邮件中发送两个表单的数据。它工作正常,但问题是我收到单行的所有数据。我想要实现的是让电子邮件中的所有数据都在线。下面我提到两种形式的PHP代码。请指导我在哪里做错了。提前致谢
Form1中:
<? php
($_POST["email"]<>'') {
$ToEmail = 'info@ad4u.pk';
$EmailSubject = 'Website Contact form';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: ".$_POST["name"]."\r\n";
$MESSAGE_BODY .= "email: ".$_POST["email"]."\r\n";
$MESSAGE_BODY .= "phone: ".nl2br($_POST["phone"])."\r\n";
$MESSAGE_BODY .= "message: ".nl2br($_POST["message"]);
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
echo "<script> alert('Messgae successfully sent!');
window.location='index.html'</script>";
exit;
?>
窗体2:
<?php
($_POST["email"]<>'') {
$ToEmail = 'info@ad4u.pk';
$EmailSubject = 'Website Price Inquiry form';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: ".$_POST["name"]."\r\n";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."\r\n";
$MESSAGE_BODY .= "Adress: ".nl2br($_POST["address"])."\r\n";
$MESSAGE_BODY .= "phone: ".nl2br($_POST["phone"])."\r\n";
$MESSAGE_BODY .= "product: ".nl2br($_POST["product"])."\r\n";
$MESSAGE_BODY .= "quantity: ".nl2br($_POST["quantity"]);
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
echo "<script> alert('Messgae successfully sent!');
window.location='index.html'</script>";
exit;
?>