the $_POST varyable is always empty in my Codeigniter controller:
controllers/Register.php
class Register extends CI_Controller
{
public function index()
{
$this->load->view('register.html');
}
public function user()
{
var_dump($_POST);
}
}
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>
<div class="form-group">
<label for="email">Email address:</label>
<input type="email" class="form-control" id="email">
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd">
</div>
<div class="checkbox">
<label><input type="checkbox"> Remember me</label>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
That is my .htaccess, i'm using it to remove index.php from my URL.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/1ドル [L]
var_dump($_POST) always output array(0) { }, but $_GET works fine. I'm on Linux (Arch), using Apache, Codeigniter 3, and PHP 7.
Sorry for my english. Thanks for all.
Edit:
$this->input->post() is empty too.
1 Answer 1
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.
Explore related questions
See similar questions with these tags.
$this->input->post(). Tryvar_dump($this->input->post());. In CI 3 you have the option of allowing$_GETin the config file. codeigniter.com/user_guide/libraries/input.htmlnameattributes for all the form elements are missing that is problemaction="<?php echo base_url('register/user');?>"make sure you have set base_url as it is required to do so in CI3 versions autoload the url helper