<分区>
我有一个 html 表单和一个 php 处理程序,但我没有收到表单应该发送的电子邮件。我已经搜索了几个小时,但我无法弄清楚。我刚开始使用 php,所以非常感谢帮助,谢谢。这是我的代码。出于安全原因,我更改了电子邮件地址。
<form action="formHandler.php" method="post">
<div class="forForm first">
<label for="namename" class="contactLabel">Name</label><br /><input placeholder="Name" class="editable" type="text" name="namename" id="namename"/>
</div>
<div class="forForm second">
<label for="emailemail" class="contactLabel">Email</label><br /><input placeholder="Email" class="editable" type="email" name="emailemail" id="emailemail" required/>
</div>
<div id="surname">
<label for="surnamesurname" class="contactLabel">Surname</label><br /><input type="text" value="Smith" class="editable" name="surnamesurname" id="surnamesurname" />
</div>
<div>
<input id="submitBTN" type="submit"/>
</div>
</form>
和 formHandler.php
<?php
$surname = $_REQUEST['surnamesurname'];
if($surname != "Smith") {
echo "We encountered a problem, please try again later1.";
}else{
$myemail = 'email@email.com';
$name = $_REQUEST['namename'];
$email = $_REQUEST['emailemail'];
$from = "oneandone.net";
$to = "contactform@domain.co.uk";
$subject = "New sign up!";
$body = "Someone new has signed up: \n Name: $name \n Email: $email";
$headers = "From: $from";
$result = "mail($to,$subject,$body,$headers)";
if(!$result){echo "your message was not sent";}
}
?>
谢谢