我正在尝试使我的联系表正常工作,但我认为我的代码中存在一些问题。
我没有收到电子邮件。这是我的html代码。也许我做错了发布方法或我的整个代码中有任何错误?
HTML
<form class="contact_form" action="send.php" method="POST" name="contact_form">
<ul>
<li>
<h2>Contact Us</h2>
<span class="required_notification">* Denotes Required Field</span>
</li>
<li>
<label for="name">Name:</label>
<input type="text" name="name" placeholder="John Doe" required />
</li>
<li>
<label for="email">Email:</label>
<input type="email" name="email" placeholder="john_doe@example.com" required />
<span class="form_hint">Proper format "name@something.com"</span>
</li>
<li>
<label for="website">Website:</label>
<input type="text" name="website" placeholder="http://johndoe.com" required pattern="(http|https)://.+"/>
<span class="form_hint">Proper format "http://someaddress.com"</span>
</li>
<li>
<label for="message">Message:</label>
<textarea name="message" cols="40" rows="6" required ></textarea>
</li>
<li>
<button class="submit" type="submit">Submit Form</button>
</li>
</ul>
</form>
</body>
</html>
PHP
<?php
if(isset($_POST['submit'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$website = $_POST['website'];
$message = $_POST['message'];
$subject = 'Message from Reef website';
$to = 'test@yahoo.com';
$headers="From: {$email}\r\nReply-To: {$email}";
mail($to,$subject,$message,$headers);
$success = "Thank you! You're email has been sent.";
}
?>
有任何 php 代码可以使用 HTML FORM 将值发布到我的电子邮件中吗?这个表单有验证,所以我不需要验证,成功后会弹出浏览器!!