How to Solve HTTP Error 405

六眼飞鱼酱① 提交于 2020-07-23 06:38:06

问题


I'm getting a HTTP Error 405 when trying to post a small form using PHP. Codes are given below. How can I solve this one?

  <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 Error message is:

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.

回答1:


I think the most likely explanation is that .php files are unmapped for POST requests in your IIS installation. This guide explains how to map extensions.




回答2:


I changed the Windows Hosting to Linux and it worked fine for me. Don't know whats wrong with the Winows hosting and the IIS. Mine was IIS 6 for the Windows hosting. But everything is fine with the Linux Hosting.



来源:https://stackoverflow.com/questions/26090967/how-to-solve-http-error-405

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!