这是我更新的代码,试图让我的表格向我发送电子邮件。我在表单周围添加了服务器 php 请求,尽管代码似乎没有读取它们。推送测试后,我的代码在网站上显示为文本。我记得有一次,我在远离表单标记的地方调用了 php,但不记得那个语法了。
这是我尝试使用的代码:
<?php
if ($_POST["email"]<>'') {
$ToEmail = 'chaseoutt@gmail.com';
$EmailSubject = 'Site 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"]."<br>";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>";
$MESSAGE_BODY .= "URL: ".$_POST["url"]."<br>";
$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])."<br>";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
?>
Your message was sent
<?php
} else {
?>
<p style="font-style:italic; font-size:12px; font-weigh: normal; margin-top: -89px; margin-left: 33px;">Contact me written in a different language.</p> <img src="http://www.cameroncashwell.com/imgs/pointing-left.png" style="float: right; margin-right: 140px; margin-top: -89px;">
<div class="form-div">
<form id="fvujq-form1" style="font-size:22px; color:#333;" method="post" action="">
<div class="form-row"><span class="label">Name *</span><input type="text" name="name" /></div>
<div class="form-row"><span class="label">Email *</span><input type="text" name="email" /></div>
<div class="form-row"><span class="label">URL</span><input type="text" name="url" /></div>
<div class="form-row"><span class="label">Comment *</span><textarea name="comment"></textarea></div>
<div class="form-row"><input class="submit" type="submit" value="Submit"></div>
</form>
</div>
<?php
};
?>
我的错误在哪里?