405 HTTP 错误 - PHP POST

发布于 2024-09-18 14:11:43 字数 4427 浏览 6 评论 0原文

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

该站点是 HTML,并且有两种 POST 到 PHP 脚本的表单(都用于发送电子邮件)。

但是,当我单击页面上的提交按钮时,会出现此错误

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

在网上浏览后,我尝试了一些解决方案,但似乎都不起作用。

我尝试添加.html 扩展名允许在 iis 管理器中进行 POST、GET(通过添加托管处理程序),但这似乎不起作用?

编辑

HTML 表单代码:

<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( "[email protected]", " 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>";
    }; 

    ?>

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> </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( "[email protected]", " 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>  $email<br></br><br></br>
    <strong>Phone:</strong>  $tel<br></br><br></br>
    <strong>Company:</strong>  $comp<br></br><br></br>
    <a //href=\"javascript:history.go(-1)\"> Click here to return to the contact page.</a></br>";
    }; 

    ?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独闯女儿国 2024-09-25 14:11:43

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文