I was reading this w3c document about post JSON data with html form, and trying to test it.
my test form is as follows:
<form action="postjson.php" method="POST" enctype="application/json">
<input type="hidden" name="touser" value="shenkwen" />
<input type="hidden" name="msgtype" value="text" />
<input type="hidden" name="agentid" value="23" />
<input type="hidden" name="text[content]" value="test message" />
<input type='submit' value="submit" />
</form>
and content for postjson.php
<?php var_dump($_POST);
I was expecting the value of $_POST being a JSON string, however, it is just a normal PHP object:
array(4) { ["touser"]=> string(8) "shenkwen" ["msgtype"]=> string(4) "text" ["agentid"]=> string(2) "23" ["text"]=> array(1) { ["content"]=> string(33) "test message" } }
I tried removing the enctype
attribute and the output is exactly the same. Then I went back to the document page and noticed that it says something indicating this standard may not be in effect.
So this is also a question about how to use W3C website, it seems to me some pages on it are just drafts. So is this page a draft? When I read pages on w3c how do I tell whether it is a draft or it is a working standard? And finally and most importantly, is enctype='application/json'
working or not?