我有一个简单的联系人,我希望通过一个函数“发布”,但我似乎无法让它工作?
当我将操作发送到外部“send.php”文件但我希望将所有内容保存在一个文件中时,该表单有效。
<form action="send()" id="contactform" method="POST">
<p>Name<input type="text" name="name">
Email
<input type="text" name="email">
Phone
<input type="text" name="phone">
</p>
<p>Message
<textarea name="message" rows="6" cols="25"></textarea>
<br />
<input type="submit" value="Send">
</p>
</form>
<?php
function send()
{
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$formcontent=" From: $name \n Phone: $phone \n Email: $email \n Message: $message";
$recipient = "email@email.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
}
?>