vaati vaati - 1 year ago 141
PHP Question

Global POST always empty


varyable is always empty in my Codeigniter controller:


class Register extends CI_Controller

public function index()



public function user()



views/register.html (view)

<form method="post" role="form" action="register/user">
<div class="form-group">
<label for="email">Name:</label>
<input type="text" class="form-control" id="name">
<div class="form-group">
<label for="email">Email address:</label>
<input type="email" class="form-control" id="email">

<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd">

<div class="checkbox">
<label><input type="checkbox"> Remember me</label>

<button type="submit" class="btn btn-default">Submit</button>

That is my
, i'm using it to remove
from my URL.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

always output
array(0) { }
, but
works fine. I'm on Linux (Arch), using Apache, Codeigniter 3, and PHP 7.

Sorry for my english. Thanks for all.


is empty too.

Answer Source

The main cause is name attributes from all the form-elements are missing

Like for example:-

<input type="text" class="form-control" id="name">

It seems you confused between id and name.

name is the attribute picked-up by $_POST.


If problem still persist then try @b-bub solution.thanks

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download