Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Problem with getting POST variables

I have a strange problem with getting POST variables. I'm using bootstrap 3.2, here is my form :

    <div class="col-sm-6" style="margin-left: 25%;">
    <form role="form" action="/home/sign-in" method="post">
        <div class="form-group">
            <label for="exampleInputEmail1">Email address</label>
            <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email">
        <div class="form-group">
            <label for="exampleInputPassword1">Password</label>
            <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
        <button type="submit" class="btn btn-default">Sign in</button>

And the action :

    public function signinAction()
        if (!$this->request->isPost()) {
            return $this->response->redirect('/');

        $usersModel = new Users();

        if (($usersModel->getEmail() == $this->request->getPost('email')) &&
            ($usersModel->getPassword() == $this->request()->getPost('password'))
        ) {
            $this->session->set(array('signin' => true));
            return $this->response->redirect('/admin/dashboard');

        $this->flashSession->error('Email/Password are wrong, please try again!');

When I'm dumping the POST variable there is nothing inside :

    array (size=0)
    array (size=0)


All your input elements need the "name" attribute. Without that attribute, the contents of the element won't be POSTed

edited Dec '14

As @quasipickle pointed out, unless you're doing an AJAX submit of the form and getting the values from another way (eg. JavaScript), the default way to retrieve data fields from sent forms its from their attribute name.

Also, keep in mind that the name must be unique as ids (despite radiobuttons). You can read more about it here.