我有一个我下载的模板,随之来了一个PHP表单。我试图填写表格并发送,但它什么也没做。控制台显示:
无法加载资源:服务器响应状态为:405(方法不允许)
HTML:
<form action="contact-form.php" method="POST" class="contact-form">
<ul class="row">
<li class="col-md-6 form-item">
<label for="contact-name"><i class="ico-male"></i></label>
<input type="text" name="contact-name" class="contact-name" id="contact-name" value="Your Name" onblur="if(this.value=='')this.value='Your Name'" onfocus="if(this.value=='Your Name')this.value=''">
</li>
<li class="col-md-6 form-item">
<label for="contact-email"><i class="ico-email"></i></label>
<input type="email" name="contact-email" class="contact-email" id="contact-email" value="Your Email" onblur="if(this.value=='')this.value='Your Email'" onfocus="if(this.value=='Your Email')this.value=''">
</li>
<li class="col-md-12 form-item">
<label for="contact-message"><i class="ico-bubble"></i></label>
<textarea name="contact-message" class="contact-message" id="contact-message" data-placeholder="Your message"></textarea>
</li>
<li class="col-md-12 form-item">
<input type="submit" name="contact-btn" class="contact-btn general-link" id="contact-btn" value="Send Your Message">
</li>
</ul>
</form><!-- end of contact form -->
PHP:
<?php
if($_POST["submit"]) {
$fromEmail = strip_tags($_POST['contact-email']);
$fromName = strip_tags($_POST['contact-name']);
$themessage = strip_tags($_POST['contact-message']);
$themessage = $themessage."The Sender Is ( ".$fromName." )" ;
$toEmail = 'jh@gmail.com';
$toName = 'JH';
Mail::send('emails.contactus', $data , function($message) use ($toEmail, $toName, $fromEmail, $fromName, $subject)
{
$message->to($toEmail, $toName);
$message->from($fromEmail, $fromName);
$message->subject($subject);
});
$headers = 'From:' .$fromName . "\r\n" .
'Reply-To:' .$fromEmail. "\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($toEmail, $subject, $themessage, $headers))
{
// Send
echo "success";
}
else{ echo "An error has be occured"; }
}
?>
我在IIS服务器上本地执行此操作并接收此内容。
我已安装PHP,现在收到此错误:
无法加载资源:服务器响应状态为500(内部服务器错误)
答案 0 :(得分:0)
在PHP站点下的IIS中,转到Handler Mappings并查找路径*.php
-
您可能有多个映射*.php
全部检查,单击编辑,然后单击请求限制按钮,单击动词选项卡。确保选中所有谓词或列出选项GET,HEAD,POST
如果你没有在IIS上安装PHP,这里有一个链接:https://php.iis.net/