从请求中获取NULL密码

时间:2015-12-21 12:02:01

标签: php symfony post request

我正试图以这种方式获得用户名和密码:

[...] \ SRC \ COMFLEX \ W2Bundle \控制器\ UserController.php

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

 public function authorizationAction(Request $request)
    {
        $user = new Models\User();
        $session = $request->getSession();

        $username = $this->get('request')->request->get('username');
        $passwd = $this->get('request')->request->get('password');

        var_dump($username);
        var_dump($passwd);
        die();

        return $this->redirectToRoute('_index');
    }

[...] \ SRC \ COMFLEX \ W2Bundle \资源\视图\主页\ index.html.twig

<form action="{{ path('comflex_w2_login_check') }}" method="post">
        <label for="username">Username:</label>
        <input type="text" id="username" name="username" />

        <label for="password">Password:</label>
        <input type="password" id="password" name="password" />

        <input type="submit" name="login" />
    </form>

但我只得到用户名变量。密码($ passwd)始终为NULL。为什么呢?

输出: string(16)“user@example.com”NULL

1 个答案:

答案 0 :(得分:0)

谢谢大家!我倾倒了帖子,有一个名为'passwd'的密钥。只需要清除缓存并再次工作。