我想知道如何在此表单中添加时间和日期,并知道访问者何时向我发送邮件。
我希望收到像
这样的邮件示例:
名称, 电子邮件, 2014年1月28日, 下午8时08分
代码:
<?php
$from = "order@email.com";
$to = "info@email.com";
$title ="My title";
$title_visitor = "Good";
$message_visitor = "Send success";
$name = $_POST["name"];
$mail = $_POST["email"];
$telefon = $_POST["phone"];
$adresa = $_POST["address"];
$kolicina = $_POST["kolicina"];
$poraka = $_POST["message"];
$grad = $_POST["city"];
if (strlen($name) > 0 && strlen($adresa) > 0 && strlen($telefon) > 0 && strlen($kolicina) > 0 && strlen($grad) > 0){
$message = '<html><body>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td><strong>Име:</strong> </td><td>" . $name . "</td></tr>";
$message .= "<tr><td><strong>Емаил:</strong> </td><td>" . $mail . "</td></tr>";
$message .= "<tr><td><strong>Телефон:</strong> </td><td>" . $telefon . "</td></tr>";
$message .= "<tr><td><strong>Адреса:</strong> </td><td>" . $adresa . "</td></tr>";
$message .= "<tr><td><strong>Адреса:</strong> </td><td>" . $grad . "</td></tr>";
$message .= "<tr><td><strong>Количина:</strong> </td><td>" . $kolicina . "</td></tr>";
$message .= "<tr><td><strong>Порака:</strong> </td><td>" . $poraka . "</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
$headers = "From: " . $from . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
mail($to, $title, $message, $headers);
if(filter_var($mail, FILTER_VALIDATE_EMAIL)){
$visitor_msg = '<html><body>';
$visitor_msg .= "<p>" . $message_visitor . "</p>";
$visitor_msg .= "</body></html>";
mail($mail, $title_visitor, $visitor_msg, $headers);
}
echo "yes";
}else{
echo "no";
}
?>
答案 0 :(得分:1)
当前日期/时间如下:
$email_date = date("Y-m-d H:i:s");
答案 1 :(得分:1)
答案 2 :(得分:1)
将以下一行添加到$message .= "</table>";
行
$message .= "<tr><td colspan=2>" . date('m/d/Y, H:i:s') . "</td></tr>";
您的来源,
$message = '<html><body>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td><strong>Име:</strong> </td><td>" . $name . "</td></tr>";
$message .= "<tr><td><strong>Емаил:</strong> </td><td>" . $mail . "</td></tr>";
$message .= "<tr><td><strong>Телефон:</strong> </td><td>" . $telefon . "</td></tr>";
$message .= "<tr><td><strong>Адреса:</strong> </td><td>" . $adresa . "</td></tr>";
$message .= "<tr><td><strong>Адреса:</strong> </td><td>" . $grad . "</td></tr>";
$message .= "<tr><td><strong>Количина:</strong> </td><td>" . $kolicina . "</td></tr>";
$message .= "<tr><td><strong>Порака:</strong> </td><td>" . $poraka . "</td></tr>";
$message .= "<tr><td ><strong>Date & Time:</strong> </td><td>" . date('m/d/Y, H:i:s') . "</td></tr>";
$message .= "</table>";
$message .= "</body></html>";