创建php联系表单

时间:2015-06-10 13:11:13

标签: php forms contact

我是php的新手,我试图编写自己的php联系表单来学习。显然现在遇到麻烦,这是我的代码:

<form action="mail-2.php" method="POST">
<p>Your Name (required)</p> <input type="text" name="name">
</br></br><p>Your Email (required)</p> <input type="text" name="email">
</br></br><p>Phone</p> <input type="text" name="phone">
</br></br>
<p>Message</p><textarea name="message" rows="6" cols="25"></textarea><br />

</br></br>
<input type="submit" name="saveForm" value="Send">
</form>

和php:mail-2.php

<?php
$to = "petermikhail96@gmail.com";
$from = $_POST['email'];
$name = $_POST['name'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$formcontent=" From: $name \n Phone: $phone \n Message: $message";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($to, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='index.html' style='text-decoration:none;color:#4A148C;'> Return Home</a>";
?>

任何人都可以帮我解决这个问题吗?点击发送后转到感谢页面,但电子邮件没有通过。

此外,我还需要在表单中添加附件,但经过多次尝试后,我认为我失败了

0 个答案:

没有答案