Skip to main content
yuany45686894
Participant
March 10, 2018
Answered

{"code":"MethodNotAllowedError","message":"POST is not allowed"}

  • March 10, 2018
  • 1 reply
  • 1562 views

Hi guys,

When I test the form and click "login",  I get this:

{"code":"MethodNotAllowedError","message":"POST is not allowed"}

*******************************************************

// index.php

<?php
$name = $_POST["name"];
$password = $_POST["password"];

$result = loginUser($name, $password);

echo $result;
?>

// .html
<form action="index.php" method="POST">
<input type="text" name="name" >
<input type="text" name="password" >
<input type="submit" value="Login" />
<form>

************************************************

Dreamweaver geniuses, can you help me please~

This topic has been closed for replies.
Correct answer BenPleysier

When the document is opened in a browser, the first thing that gets processed is the PHP bit. Problem is that, at that stage, the form has not been processed.

To stop that from happening, enclose the script in an if-statement such as

<?php

if (isset($_POST["submit"])) {

     $name = $_POST["name"];

     $password = $_POST["password"];

     $result = loginUser($name, $password);

     echo $result;

}

?>

1 reply

BenPleysier
Community Expert
BenPleysierCommunity ExpertCorrect answer
Community Expert
March 10, 2018

When the document is opened in a browser, the first thing that gets processed is the PHP bit. Problem is that, at that stage, the form has not been processed.

To stop that from happening, enclose the script in an if-statement such as

<?php

if (isset($_POST["submit"])) {

     $name = $_POST["name"];

     $password = $_POST["password"];

     $result = loginUser($name, $password);

     echo $result;

}

?>

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!