Hi guys i have simple problem that i can't seem to solve and has been frustrating me for some time i am a newbie when it comes to Codeigniter so be kind hahah, okay so on to my problem i have form validation on a subscription form that seems to not be working
Here is my controller function:
public function add_email()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('name', 'Name', 'trim|required');
$this->form_validation->set_rules('email', 'Email Address', 'trim|required|xss_clean');
if ($_POST AND $this->form_validation->run() == false)
{
redirect(base_url());
}
else
{
$data = array(
'name' => $this->input->post('name'),
'email' => $this->input->post('email')
);
$this->Newsletter->subscribe($data);
}
}
And The view:
<?= validation_errors() ?>
<?php form_open('Newsletters/add_email'); ?>
<input type="text" class="form-control" autofocus="true" id="name" name="name" placeholder="Your Name">
<input type="email" class="form-control" id="email" name="email" placeholder="Email address">
<input class="btn btn-primary btn-block" type="submit" value="SIGN ME UP" id="subscribe">
<?php form_close(); ?>
So when i want to test if validation is working and i press sign up nothing happens and no validations errors show! So what am i doing wrong?