2014-09-29 72 views
0

當使用PHP嘗試使用post小表單時,出現HTTP錯誤405。代碼如下。我該如何解決這個問題?如何解決HTTP錯誤405

<div class="quiz-section"> 
      <form action="quiz.php" method="post"> 
       ################# 
      <input type="submit" class="btn blue" name="submitQuiz" value="Submit" /> 
     </form> 
    </div> 





<?php 
    if (isset($_POST['submitQuiz'])) { 
     if(isset($_POST['quest1'])&&isset($_POST['quest2'])&&isset($_POST['quest3'])) 
     { 
      if(($_POST['guestName']!="")&&($_POST['guestEmail']!="")){ 

       $to  = 'a######@yahoo.com'; 
       $subject = 'Quiz Answer Submission'; 
       $message = "Submited by: ".$_POST['guestName']." From email: ".$_POST['guestEmail']." Answers are: ".$_POST['quest1'].", ".$_POST['quest2'].", ".$_POST['quest3']; 

       $headers = 'From: j#####@live.in' . "\r\n" . 
        'Reply-To: '.$_POST["guestEmail"] . "\r\n" . 
        'X-Mailer: PHP/' . phpversion(); 

       mail($to, $subject, $message, $headers); 
       echo "Thanks for your submission. We successfully received your answers. Stay tuned."; 
       //header("Location: index.html#quiz-questions?status=Success"); 
      } 
      else{ 
        echo "Please go back and answer all quiz questions"; 
      } 
     } 
     else{ 
       echo "Please fill all the fields and answer to all questions"; 
       //header("Location: index.html#quiz-questions?status=Error"); 
     } 
    } 
?> 

的錯誤信息是:

The page cannot be displayed 

The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access. 
Please try the following: 

Contact the Web site administrator if you believe that this request should be allowed. 
Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly. 
HTTP Error 405 - The HTTP verb used to access this page is not allowed. 
Internet Information Services (IIS) 

Technical Information (for support personnel) 

Go to Microsoft Product Support Services and perform a title search for the words HTTP and 405. 
Open IIS Help, which is accessible in IIS Manager (inetmgr), and search for topics titled Setting Application Mappings, Securing Your Site with Web Site Permissions, and About Custom Error Messages. 
+0

[405 HTTP錯誤 - PHP POST]可能的重複(http://stackoverflow.com/questions/3677751/405-http-error-php-post) – TML 2014-09-29 00:30:16

+0

在你的'&& isset ....中添加空格....'聲明,也檢查文件權限 – Ahmad 2014-09-29 00:31:03

+0

@TML,它沒有一個正確的答案! – user1012181 2014-09-29 01:21:23

回答

0

我將Windows主機改爲Linux,對我來說工作得很好。不知道Winows託管和IIS有什麼問題。我的Windows是用於IIS的IIS 6。但Linux主機一切正常。

0

我認爲最可能的解釋是,.php文件是未映射在你的IIS安裝POST請求。 This guide解釋瞭如何映射擴展。

+0

這沒有幫助。無論如何要在Godaddy中配置ISS? – user1012181 2014-09-29 00:59:25

+0

我認爲問題一定是其他問題。我一直認爲PHP可以在共享主機中正確配置,或者根本不配置。 – gandaliter 2014-09-29 01:02:59

+0

幾天前它開始工作,突然間它開始顯示這個錯誤。 – user1012181 2014-09-29 01:06:03