HTTP Error 405.0 - Method Not Allowed, with POST

走远了吗. 提交于 2019-12-12 06:45:21

问题


I am trying to use isset($_POST['Save']) in my php file to save result in database.

echo "<form action='' method='POST'>";
echo "<input name='Save' type='submit' value='Save Result'>";
echo "</form>";
if(isset($_POST['Save']))
{
    include('saveResult.php');
}

saveResult.php:

<?php
if(isset($_POST['Save'])) // If the submit button was clicked
{
$serverName = "Alaa";
echo"saveResult function php";
$connectionInfo = array( "Database"=>"i2b2blast", "UID"=>"i2b2blast", "PWD"=>"demouser");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}

$sql = "INSERT INTO BlastQueryDim (QueryID, QuerySeq) VALUES ('9', 'q')";

$stmt = sqlsrv_query( $conn, $sql);
if( $stmt === false ) {
     die( print_r( sqlsrv_errors(), true));
}
}
?>

but, I got this error:

HTTP Error 405.0 - Method Not Allowed The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used. The request sent to the Web server used an HTTP verb that is not allowed by the module configured to handle the request. A request was sent to the server that contained an invalid HTTP verb. The request is for static content and contains an HTTP verb other than GET or HEAD. A request was sent to a virtual directory using the HTTP verb POST and the default document is a static file that does not support HTTP verbs other than GET or HEAD.

Any help please?


回答1:


There is a syntax error.
Try this:

    include 'filename';


来源:https://stackoverflow.com/questions/35955747/http-error-405-0-method-not-allowed-with-post

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