这是我的PHP代码,我想以某种方式更改用户在提交表单时看到的消息,其中包含“Ben,您的消息已被发送!”之类的名称。我也希望保持它的样式,但现在包括名称。
<?php
if(isset($_POST['submit'])){
$to = "benlevygraphics@gmail.com";
$headers = "From: " . $_POST['email'];
$subject = "Ben, you have been contacted...";
$body = "Name: " . $_POST['name'] . "\nEmail: " . $_POST['email'] . "\nWebsite: " . $_POST['web'] . "\nMessage: " . $_POST['message'];
if(mail($to, $subject, $body, $headers)){
echo("<p class=contactformsent>Your message has been sent!</p>");
}
else{
echo("<p class=contactformnotsent>Message delivery failed...</p>");
}
}
?>
答案 0 :(得分:1)
试试这个
$name = $_POST['name'];
echo("<p class=contactformsent>".$name." Your message has been sent!</p>");
答案 1 :(得分:0)
所以在邮件中插入名称:
echo("<p class=contactformsent>".$_POST['name'].", your message has been sent!</p>");