phpについて勉強中です。
htmlのformからpostでjsonをphpファイルに送りたいのですが。
取得はできたのですがjsom_decodeがnullになってしまいます。
html
1<html> 2 <head> 3 <meta http-equiv="content-language" content="ja" /> 4 <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> 5 <meta http-equiv="content-style-type" content="text/css" /> 6 <meta http-equiv="content-script-type" content="text/javascript" /> 7 <meta http-equiv="pragma" content="no-cache" /> 8 </head> 9 <body> 10 <form name ="DeviceInfo" method="post" action="http://***.***.jp/***/test.php"> 11 <input type="text" name="0001TEST" value='{"Info":[{"id":"100","name":"テストA","testID1":"TestAAAAA-001","testID2":"1","testID3":"5","memo":"備考"}]}' /> 12 <input type="submit" value="submit"/> 13 </form> 14 </body> 15</html>
php
1$json_string = file_get_contents('php://input'); 2$obj = json_decode($json_string);
送るjsonが「"」が抜けてたり「'」だったり末尾に「,」がついているのかと思いチェックしましたが他にもダメな理由があるのでしょうか。
よろしくお願いします
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/03/14 08:31