使用PHP尝试post
小表格时,我收到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 :(得分:0)
我认为最可能的解释是,在IIS安装中,.php
文件未针对POST请求进行映射。 This guide解释了如何映射扩展程序。
答案 1 :(得分:0)
我将Windows主机更改为Linux,它对我来说很好。不知道Winows托管和IIS有什么问题。我的Windows主机是IIS 6。但是Linux Hosting的一切都很好。