[eluser]opel[/eluser]
I have a newsletter sign up for that I want to include on my site on different pages.
I have created a method "newsletter" in my contact controller like so :
Code:
function newsletter()
{
if ($this->input->post('submit'))
{
$this->form_validation->set_rules('newsletter_name', 'name', 'trim|required');
$this->form_validation->set_rules('newsletter_email', 'email', 'trim|required|valid_email');
if ($this->form_validation->run() !== FALSE)
{
$this->load->library('Mailinteractive');
$custom_fields = array("21" => ($this->input->post('newsletter_name')));
$mailing_list = 913;
$this->mailinteractive->subscribe($this->input->post('newsletter_email'), $mailing_list, $custom_fields);
$this->session->set_flashdata('message', 'Your email has been succsefully added to our mailing list.');
redirect($this->input->post('newsletter_url'));
}
else
{
redirect($this->input->post('newsletter_url'));
}
}
}
If a form is successful it redirects back to the page the form was posted from. The problem I am having is to get the validation error messages to post back to the form.
I have included the validation errors function at the top of my include file so that it appears with the form.
Any ideas on how I can get the validation errors to post back please ?