CASE 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
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 "-"
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 "-"
Regards and thank´s
Case 1:
tester-test-t
means
take value of constant
tester
, substract value of constanttest
, substract value of constantt
.
The result of substraction will be the key in a $_POST
array.
Do you have such constants in your code? Surely, you don't .
Case 2:
'tester-test-t'
is just a string. And string key 'tester-test-t'
exists in your $_POST
Case 3:
tester_test_t
is considered a constant again. Do you have constant tester_test_t
defined? Surely, you don't .
And to understand what's going wrong in your code - use error_reporting
(thanks @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. 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".
Personally I prefer to specify an action="" with the name of another .php script to do the processing of the form. I find submitting the form back to itself can get confusing.
Rgds
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.