表单返回的内容不出现在我的代码后端。

huangapple go评论56阅读模式
英文:

the return from the form doest appeare in the backend side of my code

问题

当我点击提交时,没有任何反应。我检查了 var_dump($_POST) 但仍然没有返回任何内容。我还尝试了将整个 $_POST 数组输出,但是没有值被打印出来。

英文:

I am working on a small project to learn more about HTTP request methods using PHP. As a simple example, I want to take the value from user input and do text transformation on it, then return it to the user.

html

<form action="index.php"    method="GET">
    <input type="text" placeholder="Enter name" name="name"/>
    <input type="submit" value="Go" name="submit"/>
</form>

php

<?php
if(isset($_POST["submit"])) {
    $name = $_POST["name"];
    $result = strtoupper($name);
    echo $result;
}
?>

When I click on submit, nothing happens. I checked var_dump($_POST) but it still returns nothing. What am I missing?

I also did a check on dumping the entire $_POST array but no value is printed out.

答案1

得分: -1

你的表单请求是通过 GET 方法进行的,而不是 POST。请将你的表单方法从 method="GET" 更改为 method="POST"

英文:

You form request is going through GET method and not POST. Change your form method from this method="GET" to this method="POST".

huangapple
  • 本文由 发表于 2023年2月27日 07:14:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/75575585.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定