我正在尝试制作一个简单的 php 表单邮件。
我所追求的只是一封看起来很漂亮的电子邮件
Name: joe blogs
Email: joe@blogs.co.uk
Message: anything.
Answer 1: Red
Answer 2: green
Answer 3: Blue
在下面的示例中,我删除了我的电子邮件地址...问题是我填写了字段并点击了提交按钮,我收到消息说消息已发送,但没有收到任何电子邮件。在我添加 $questX 字段之前一切正常,然后它停止工作。但我认为提交的 $name 没有区别。所以我很困惑。
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$name = $_REQUEST['name'] ;
$quest = $_REQUEST['quest'] ;
$questb = $_REQUEST['questb'] ;
$questc = $_REQUEST['questc'] ;
$subject = "Competition Entry" ;
$message = $_REQUEST['message'] ;
mail("MYEMAIL@HOME.com", $subject, "Name:" . $name, "From:" . $email, "Answer 1:" .
$quest, "Answer 2:" . $questb, "Answer 3:" . $questc, $message );
echo "Thank you for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='win-a-deck2.php'>
<label for='name'>Name:</label><input name='name' type='text' placeholder='Enter your fullname'><br>
<label for='email'>Email:</label><input name='email' type='text'><br>
<label for='message'>Message:</label><br>
<input name='message' type='text'><br>
<label for='quest'>Question 1:</label><input name='quest' type='text' placeholder='Answer to Question 1'><br>
<label for='questb'>Question 2:</label><input name='questb' type='text' placeholder='Answer to Question 2'><br>
<label for='questc'>Question 3:</label><input name='questc' type='text' placeholder='Answer to Question 3'><br>
<input type='submit'>
</form>";
}
?>