Php IIS 7.5上出现405 HTTP谓词错误的简单电子邮件表单
我正在尝试建立一个建议箱表单,通过电子邮件发送建议。 此页面位于内部IIS服务器上。 当我选择Submit时,服务器返回405错误: 服务器错误 405-不允许使用HTTP谓词访问此页。 无法显示您正在查找的页面,因为尝试访问时使用了无效的方法(HTTP谓词) 以下是html:Php IIS 7.5上出现405 HTTP谓词错误的简单电子邮件表单,php,html,forms,iis,Php,Html,Forms,Iis,我正在尝试建立一个建议箱表单,通过电子邮件发送建议。 此页面位于内部IIS服务器上。 当我选择Submit时,服务器返回405错误: 服务器错误 405-不允许使用HTTP谓词访问此页。 无法显示您正在查找的页面,因为尝试访问时使用了无效的方法(HTTP谓词) 以下是html: <body> <!-- Start code for the form--> <form method="post" name="myemailform" action="form-to-
<body>
<!-- Start code for the form-->
<form method="post" name="myemailform" action="form-to-email.php">
<p>
<label for='name'>Enter Name: </label><br>
<input type="text" name="name">
</p>
<p>
<label for='email'>Enter Email Address:</label><br>
<input type="text" name="email">
</p>
<p>
<label for='message'>Enter Message:</label> <br>
<textarea name="message"></textarea>
</p>
<input type="submit" name='submit' value="submit">
</form>
</body>
输入名称:
输入电子邮件地址:
输入消息:
这里是php
<?php
if(!isset($_POST['submit']))
{
//This page should not be accessed directly. Need to submit the form.
echo "error; you need to submit the form!";
}
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$message = $_POST['message'];
//Validate first
if(empty($name)||empty($visitor_email))
{
echo "Name and email are mandatory!";
exit;
}
if(IsInjected($visitor_email))
{
echo "Bad email value!";
exit;
}
$email_from = 'internal@domain.com';
$email_subject = "New Form submission";
$email_body = "You have received a new message from the user $name.\n".
"Here is the message:\n $message".
$to = "internal@domain.com";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
//Send the email!
mail($to,$email_subject,$email_body,$headers);
done. redirect to thank-you page.
header('Location: thank-you.html');
// Function to validate against any email injection attempts
function IsInjected($str)
{
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str))
{
return true;
}
else
{
return false;
}
}
?>
任何帮助都将不胜感激。我是个新手,只知道这可能是服务器配置或路径语法问题。我想你的行
完成了。重定向到感谢页面。
应该是注释Yes。它在实际代码中。当我抄到这篇文章时,我错过了它。仍然会出错。从我收集的信息来看,它在命中php文件时正好遇到了一个错误。我设置了一个非常简单的html文件,其中包含基本的php。html代码可以工作,但没有显示php回音<代码>代码测试PHP页面代码
我更接近了!我将FastCGI和PHP添加到IIS服务器。现在没有错误,我只是没有收到任何电子邮件(