405 HTTP错误 - PHP POST [英] 405 HTTP Error - PHP POST

查看:237
本文介绍了405 HTTP错误 - PHP POST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows Server 2008上运行了一个站点。



该站点是HTML,并且具有两种向PHP脚本进行POST的形式(均可发送电子邮件)。



当我点击页面上的提交按钮时,出现这个错误


$ b

405 - 使用HTTP动词不允许访问此页面
您正在查找的页面无法显示,因为使用了无效的方法(HTTP动词)来尝试访问。



在网络上浏览后,我尝试了一些解决方案,但似乎没有任何解决方案。



我试过在iis Manager中添加允许POST,GET的.html扩展(通过添加一个托管处理程序),但是这似乎不起作用。



有什么想法?任何帮助,将不胜感激!

编辑:

HTML FORM CODE:

 < form id =form1name =form1method =postaction =mail.php> 
< fieldset>
< legend>< strong>请填写我们的联系表单< / strong>< / legend>
< table width =622border =0>
< tr>
< td width =277>名称*< / td>
< td width =335>< input class =purplename =nicknametype =textid =nickname/>< / td>
< / tr>
< tr>
< td>电子邮件*< / td>
< td>< input class =purplename =emailtype =textid =email/>< / td>
< / tr>
< tr>
< td>电话号码< / td>
< td>< input class =purplename =teltype =textid =tel/>< / td>
< / tr>
< tr>
< td>公司名称*< / td>
< td>< input class =purplename =comptype =textid =comp/>< / td>
< / tr>
< tr>
< td>查询< / td>
< td>< textarea class =purplename =messagecols =53rows =10id =message>< / textarea>< / td>
< / tr>
< tr>
< td colspan =2align =center>< input name =Submittype =submitvalue =Submit/>
< label>
< input name =resettype =resetid =resetvalue =Reset/>
< input type =hiddenname =ipvalue =echo $ REMOTE_ADDR;/>
< / label>< / td>
< / tr>
< tr>
< td> *必填字段< / td>
< td>< / td>
< / tr>
< tr>
< td colspan =2>< h3>为什么不打电话给我们? 021 4868150< / h3>
< p>& nbsp;< / p>< / td>
< / tr>
< / table>
< / fieldset>
< / form>

PHP脚本

 <?php 
$ nickname = $ _REQUEST ['nickname'];
$ email = $ _REQUEST ['email'];
$ tel = $ _REQUEST ['tel'];
$ comp = $ _REQUEST ['comp'];
$ message = $ _REQUEST ['message'];


//让我们来看看是否所有字段都被填入!
if(empty($ nickname)|| empty($ email)|| empty($ comp))
{
$ error =所有必填字段尚未完成,< ; a href = \javascript:history.go(-1)\>请点击此处返回。< / a>;
}
else
{
$ content =$昵称已从ePubDirect向您发送电子邮件
查询:
$消息
< br />个人的其他相关详情:< br /

mail(xxxxxxx@gmail.com,Query,$ content,From:$ email); //首先必须解决它将要发生的问题,然后邮件的主题应该是什么,内容和来自将作为查询提交者的地址。
echo< h2> $昵称< / h2>< br>< / br>
您的查询已成功发送。< br>< / br>< br>< < / br>< br>< / br>< br>< / br>我们会处理这个查询并尽快与您联系。
您提交的联系详情为:< br>< / br>< br>< / br>
< strong>电子邮件:< / strong>& nbsp; $ email< ;< br>< / br>< br>< / br>< br>< br>电话:< / strong>& nbsp; $ tel< br>< < / br>
< strong>公司:< / strong>& nbsp; $ comp< br>< / br>< br>< / br>
< a //href=\\"javascript:history.go(-1)\\">点击此处返回联系人页面。< / a>< / br>;
};

?>


解决方案

是否将IIS配置为处理POST动词的PHP文件?听起来你需要为PHP文件添加POST动词,而不是HTML文件。


I have a site running on windows server 2008.

The site is HTML, and has two forms which POST to PHP scripts (both to send an email).

This error comes up however when I click the submit button on the page

"405 - HTTP verb used to access this page is not allowed. The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access."

After looking around on the web, I've tried a few solutions but none seem to work.

I've tried adding a .html extension allowing POST, GET in iis Manager (through adding a managed handler) however this doesn't seem to work.

any ideas? any help would be appreciated!

EDIT:

HTML FORM CODE:

<form id="form1" name="form1" method="post" action="mail.php">
           <fieldset>
           <legend><strong>Please fill out our contact form</strong></legend>
            <table width="622" border="0">
              <tr>
                <td width="277">Name*</td>
                <td width="335"><input class="purple" name="nickname" type="text" id="nickname" /></td>
              </tr>
              <tr>
                <td>EMail*</td>
                <td><input class="purple" name="email" type="text" id="email" /></td>
              </tr>
              <tr>
                <td>Phone No.</td>
                <td><input class="purple" name="tel" type="text" id="tel" /></td>
              </tr>
              <tr>
                <td>Company Name*</td>
                <td><input class="purple" name="comp" type="text" id="comp" /></td>
              </tr>
              <tr>
                <td>Query</td>
                <td><textarea class="purple" name="message" cols="53" rows="10" id="message"></textarea></td>
              </tr>
              <tr>
                <td colspan="2" align="center"><input name="Submit" type="submit" value="Submit"/>
              <label>
                  <input name="reset" type="reset" id="reset" value="Reset" />
                  <input type="hidden" name="ip" value=" echo $REMOTE_ADDR; " />
              </label></td>
                </tr>
                <tr>
                <td>*Required Fields</td>
                <td></td>
              </tr>
               <tr>
                <td colspan="2"><h3>Why not call us? 021 4868150</h3>
                 <p>&nbsp;</p></td>
              </tr>
            </table>
            </fieldset>
        </form>

PHP SCRIPT

<?php
      $nickname = $_REQUEST['nickname'] ;
      $email = $_REQUEST['email'] ;
      $tel = $_REQUEST['tel'] ;
      $comp = $_REQUEST['comp'] ;
      $message = $_REQUEST['message'] ;


    // Let's check if all fields are filled in!
    if(empty($nickname) || empty($email) || empty($comp))
    {
    $error = "All of the required fields have not been completed, <a href=\"javascript:history.go(-1)\">please click here to go back.</a>";
    }
    else
    {
    $content= "$nickname has sent you an e-mail from ePubDirect
    Query:
    $message
    You can contact $nickname via Email: $email. <br />Other relevant details of individual: <br />Telephone Number: $tel <br />Company: $comp";

    mail( "xxxxxxx@gmail.com", " Query", $content, "From: $email"); //first thing has to be address it is going to, then what the subject of the mail should be, the content and a from address which will be the query submitter.
    echo  "<h2>$nickname</h2><br></br>
    Your query has been succesfully sent. <br></br><br></br>
    We will deal with this query and be in touch as soon as possible.<br></br><br></br><br></br> 
    The contact details you submitted are: <br></br><br></br>
    <strong>Email:</strong>&nbsp; $email<br></br><br></br>
    <strong>Phone:</strong>&nbsp; $tel<br></br><br></br>
    <strong>Company:</strong>&nbsp; $comp<br></br><br></br>
    <a //href=\"javascript:history.go(-1)\"> Click here to return to the contact page.</a></br>";
    }; 

    ?>

解决方案

Is IIS configured to handle PHP files for POST verbs? It sounds like you need to add the POST verb for PHP files, not HTML files.

这篇关于405 HTTP错误 - PHP POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆