Php silex是否将表单数据传递到另一页?

Php silex是否将表单数据传递到另一页?,php,symfony,silex,Php,Symfony,Silex,我对silex和symfony真的很陌生。这是我第一次进入silex。我在app.php文件中创建了表单的代码,这些代码来自于对文档的一点修改、复制和粘贴 现在我如何将这些数据传递到另一个页面 我想创建一个只转储post/get数组的页面,让我了解如何传递get/post变量 以下是我的应用程序文件的一部分: <?php /** /src/app.php */ use Symfony\Component\HttpFoundation\Request; use Symfony\Compone

我对silex和symfony真的很陌生。这是我第一次进入silex。我在app.php文件中创建了表单的代码,这些代码来自于对文档的一点修改、复制和粘贴

现在我如何将这些数据传递到另一个页面

我想创建一个只转储post/get数组的页面,让我了解如何传递get/post变量

以下是我的应用程序文件的一部分:

<?php
/** /src/app.php */
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

    /**
     * Register new application
     */
    $app = new Application();
    // skip to the form part ...
        $app->match('/', function (Request $request) use ($app) {
            // some default data for when the form is displayed the first time
            $data = array(
                'name' => 'Your name',
                'email' => 'Your email',
            );

            $form = $app['form.factory']->createBuilder('form', $data)
                ->add('name')
                ->add('email')
                ->add('gender', 'choice', array(
                    'choices' => array(1 => 'male', 2 => 'female'),
                    'expanded' => true,
                ))
                ->getForm();

            if ('POST' == $request->getMethod()) {
                $form->bindRequest($request);

                if ($form->isValid()) {
                    $data = $form->getData();

                    // do something with the data

                    // redirect somewhere
                    return $app->redirect('completed');
                }
            }

            // display the form
            return $app['twig']->render('index.html', array('form' => $form->createView()));
        });

您可以尝试使用转发


你可以试着用前锋


你能预料到seg出现故障的原因吗?当我通过$params时会得到一个参数。如何访问发送的参数?如果有一个POST请求,情况会怎样?请解释一下。提供的答案不充分。您是否能预测seg故障错误的原因?当我通过$params时会得到一个参数。如何访问发送的参数?如果有一个POST请求,情况会怎样?请解释一下。提供的答案是不够的
<?php  // app.php  
    $app->match('complete') use function ($app) {
          // sorry psuedocode
         foreach ($REQUEST as $key=> $var) {
         echo "$key: $var";
         }
        }
// where params is the values from your POST
$subRequest = Request::create('/otherpage', 'GET', $params);

return $app->handle($subRequest, HttpKernelInterface::SUB_REQUEST);