dongshao8125 2015-12-08 16:57
浏览 120

如何使用php在slim框架中使用request-> getBody()获取表单数据?

I am trying the fetch the form data. I dont know where the mistake is.

<html>
<head>
<title>Student</title>
</head>
<body>
<form name="std" action="insert/std_insert" method="POST">
Student id:<input type="text" name="std_id" id="std_id"><br>
Student name:<input type="text" name="std_name" id="std_name"><br>
<input type="submit" name="submit" value="submit">
</body>
</html>

This is the code for fetching

<?php
error_reporting(0);
$app = new \Slim\Slim();
$body = $app->request->getBody();
echo json_encode($body);
?>
  • 写回答

2条回答 默认 最新

  • doutan3040 2015-12-10 21:17
    关注

    The request object is not full-filled until the app has been run. IE $app->run(); You are actually not using Slim correctly. docs.slimframework.com

    评论

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面