My problem seams to be simple, but I am struggling to get this to work.
Here's my html:
<form class="form" role="form" id="form" method="post" action="<?php echo site_url("register"); ?>" onsubmit="" >
<div class="col-md-6 col-sm-6 col-xs-12 fm">
<input type="text" class="form-control" id="email" name="email"
value="<?php if(isset($validation_errors['post_data']['email'])) echo $validation_errors['post_data']['email']; ?>"
placeholder="Email" >
</div>
<div class="text-center">
<input type="submit" id="btn" name="btn" class="btn" value="Quero ganhar um Cartão">
</div>
</form>
I made the code a bit simple, so you could read it fast. When I submit the form to the register page, I try to see if it is a post or not like this :
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Register extends CI_Controller {
function Register() {
parent::__construct();
$this->load->model('register_model');
}
public function index() {
if($_POST) { echo 'post'; } else { echo 'not a post'; }
}
}
And the controller keeps printing 'not a post'. It seams like the form only redirect to the URL and do nothing more.
Edit :
I did echo $_SERVER['REQUEST_METHOD'];
in my controller and it prints " GET ", so, I guess something is wrong with the method ? I Already tried method="POST"
, method="post"
and it keeps printing " GET ". Don't know what else to do.