Html PHP web表单不发送电子邮件?

Html PHP web表单不发送电子邮件?,php,html,forms,webforms,Php,Html,Forms,Webforms,我用php脚本创建了一个html表单,以便在用户点击“发送”时ping一封电子邮件。但是,当点击“发送”时,我收到一个错误,请更正以下错误:“有人能告诉我是否正确连接了表单,或者我的php脚本是否错误。谢谢 contact.htm <html> <body> <p>Required fields are <b>bold</b></p> <form action="contact.php" method="post"

我用php脚本创建了一个html表单,以便在用户点击“发送”时ping一封电子邮件。但是,当点击“发送”时,我收到一个错误,请更正以下错误:“有人能告诉我是否正确连接了表单,或者我的php脚本是否错误。谢谢

contact.htm

<html>
<body>

<p>Required fields are <b>bold</b></p>

<form action="contact.php" method="post">
<p><b>Your Name:</b> <input type="text" name="yourname" /><br />
<b>Subject:</b> <input type="text" name="subject" /><br />
<b>E-mail:</b> <input type="text" name="email" /><br />
Website: <input type="text" name="website"></p>

<p>Do you like this website?
<input type="radio" name="likeit" value="Yes" checked="checked" /> Yes
<input type="radio" name="likeit" value="No" /> No
<input type="radio" name="likeit" value="Not sure" /> Not sure</p>

<p>How did you find us?
<select name="how">
<option value=""> -- Please select -- </option>
<option>Google</option>
<option>Yahoo</option>
<option>Link from a website</option>
<option>Word of mouth</option>
<option>Other</option>
</select>

<p><b>Your comments:</b><br />
<textarea name="comments" rows="10" cols="40"></textarea></p>

<p><input type="submit" value="Send it!"></p>

<p> </p>

</form>

</body>
</html>
谢谢

<html>
<body>

<p><b>Your message was sent</b></p>

<p>Your message was successfully sent!
Thank you for contacting us, we will reply
to your inquiry as soon as possible!</p>

</body>
</html>
contact.php

<?php

$myemail  = "gregtwardochleb@hotmail.co.uk";

$yourname = check_input($_POST['yourname'], "Enter your name");
$subject  = check_input($_POST['subject'], "Write a subject");
$email    = check_input($_POST['email']);
$website  = check_input($_POST['website']);
$likeit   = check_input($_POST['likeit']);
$how_find = check_input($_POST['how']);
$comments = check_input($_POST['comments'], "Write your comments");

if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("E-mail address not valid");
}

if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/i", $website))
{
$website = '';
}

$message = "Hello!

Your contact form has been submitted by:

Name: $yourname
E-mail: $email
URL: $website

Like the website? $likeit
How did he/she find it? $how_find

Comments:
$comments

End of message
";

mail($myemail, $subject, $message);

header('Location: thanks.htm');
exit();

function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
    show_error($problem);
}
return $data;
}

function show_error($myError)
{
?>
<html>
<body>

<b>Please correct the following error:</b><br />
<?php echo $myError; ?>

</body>
</html>
<?php
exit();
}
?>

您的HTML页面将被重定向到联系人页面。在联系人页面中,您已经编写了代码

<b>Please correct the following error:</b><br />

请让我知道您到底想做什么。

您缺少一些输入,因为您在contact.php之类的网站中包含了一些输入,例如您没有从表单输入中发布的内容

<html>
<body>
 <form action="contact.php" method="post">
  <p><b>Your Name:</b> <input type="text" name="yourname" /><br />
  <b>Subject:</b> <input type="text" name="subject" /><br />
  <b>E-mail:</b> <input type="text" name="email" /><br />
  <b>Website:</b> <input type="text" name="website" /><br />
  <b>Like the website:</b> <input type="text" name="likeit" /><br />
  <b>How did he/she find it:</b> <input type="text" name="how" /><br />
  <p><b>Your comments:</b><br />
  <textarea name="comments" rows="10" cols="40"></textarea></p>
  <p><input type="submit" value="Send it!"></p>
 </form>
</body>
</html>

php邮件功能在本地主机上不起作用,因为它需要域信息来发送邮件。所以你必须先把它放在服务器上。希望它能为您工作

您好,首先,当用户点击“发送”确认电子邮件已发送时,我希望出现一个感谢页面。其次,我希望提交的用户详细信息能够到达他们的目的地,所以公司所有者的电子邮件地址。我已经添加了缺少的输入字段,但是仍然是相同的结果。您在本地主机或服务器上使用它吗?如果您在服务器上使用它,那么您可以为我提供此代码的实时链接吗?目前是本地的。我想在我把它投入使用之前让它工作起来。这3个文件直接位于web forms文件夹中。php邮件功能在本地主机上不起作用,因为它需要域信息来发送邮件。所以你必须先把它放在服务器上。希望它对你有用。哦,好的,这就解释了一切。今晚我将在服务器上试用,希望它能发送电子邮件。我将与您联系,了解最新情况。谢谢你的帮助!
<html>
<body>
 <form action="contact.php" method="post">
  <p><b>Your Name:</b> <input type="text" name="yourname" /><br />
  <b>Subject:</b> <input type="text" name="subject" /><br />
  <b>E-mail:</b> <input type="text" name="email" /><br />
  <b>Website:</b> <input type="text" name="website" /><br />
  <b>Like the website:</b> <input type="text" name="likeit" /><br />
  <b>How did he/she find it:</b> <input type="text" name="how" /><br />
  <p><b>Your comments:</b><br />
  <textarea name="comments" rows="10" cols="40"></textarea></p>
  <p><input type="submit" value="Send it!"></p>
 </form>
</body>
</html>