[英]PHP does not receive values from post form
CASE 1情况1
if i put this , i can´t receive the end value from input如果我把这个,我不能从输入接收最终值
<?php echo $_POST[tester-test-t]; ?>
<form action="" method="post"> <input type="text" name="tester-test-t" value="" /> <input type="submit" name="Send" value="Sender" /> </form>
CASE 2案例二
if i put this i can receive value from form如果我把这个我可以从表格中获得价值
<?php echo $_POST['tester-test-t']; ?>
<form action="" method="post"> <input type="text" name="tester-test-t" value="" /> <input type="submit" name="Send" value="Sender" /> </form>
CASE 3案例3
And finally if i put this , also i can received the value from POST form , as you can see i puto "_" and not the same as in the case 1 "-"最后,如果我放了这个,我也可以从 POST 表单中收到值,正如你所看到的,我输入了“_”而不是与情况 1“-” 相同
echo $_POST[tester_test_t];
<form action="" method="post"> <input type="text" name="tester-test-t" value="" /> <input type="submit" name="Send" value="Sender" /> </form>
The question it´s about , which it´s the problem for not receive the value from post form in the case 1 and yes , in the other cases with '' and with "-"它是关于的问题,这是在案例 1 和 yes 中未从 post 表单接收值的问题,在其他情况下使用 '' 和 "-"
Regards and thank´s问候和感谢
Case 1:情况1:
tester-test-t
means tester-test-t
表示
take value of constant
tester
, substract value of constanttest
, substract value of constantt
.取常数tester
值,减去常数test
值,减去常数t
值。
The result of substraction will be the key in a $_POST
array.减法的结果将是$_POST
数组中的键。
Do you have such constants in your code?你的代码中有这样的常量吗? Surely, you don't .当然,你没有。
Case 2:案例2:
'tester-test-t'
is just a string. 'tester-test-t'
只是一个字符串。 And string key 'tester-test-t'
exists in your $_POST
您的$_POST
存在字符串键'tester-test-t'
Case 3:案例3:
tester_test_t
is considered a constant again. tester_test_t
再次被视为常量。 Do you have constant tester_test_t
defined?您是否定义了常量tester_test_t
? Surely, you don't .当然,你没有。
And to understand what's going wrong in your code - use error_reporting
(thanks @Fred -ii-)并了解您的代码出了什么问题 - 使用error_reporting
(感谢@Fred -ii-)
It's likely to be something to do with character encoding, and how the - gets treated as it is passed into an http request as the form gets submitted.这可能与字符编码有关,以及 - 在表单提交时传递到 http 请求时如何处理。 The - is likely getting encoded in a certain way and causing you problems. - 可能会以某种方式编码并导致您出现问题。
A simple solution is getting rid of the hyphens in your field name, so change name="tester-test-t" to something like name="TesterTestT".一个简单的解决方案是去掉字段名称中的连字符,因此将 name="tester-test-t" 更改为 name="TesterTestT" 之类的内容。
Personally I prefer to specify an action="" with the name of another .php script to do the processing of the form.我个人更喜欢用另一个 .php 脚本的名称指定一个 action="" 来处理表单。 I find submitting the form back to itself can get confusing.我发现将表单提交回本身可能会让人感到困惑。
Rgds Rgds
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.