[eluser]Steve Goodwin[/eluser]
So i've been playing around with this most of the afternoon, i've read the documentation and tried multiple ways of calling this in the code, but still no joy.
I want to check weather the users email is unique, the table is called "member_tbl" and the field is called "email".
My controller code is as below:
Code:
public function register()
{
$this->load->helper('form');
$this->load->library('form_validation');
if($this->input->post())
{
$this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[member_tbl.email]');
if ($this->form_validation->run() == FALSE)
{
$data['content'] = "<strong>Form produced Errors</strong>";
}
else
{
$data['content'] = "Form was processed successfully!";
}
}
else
{
$data['content'] = "Register";
}
$data['title'] = "Member Registration";
$this->load->view('member/register', $data);
}
My View code is below:
Code:
<p><?php echo $content; ?></p>
<form name="member-registration" method="post" action="/member/register/">
<div class="grid_2">
<label for="email">Email: <span class="required">*</span></label>
</div>
<div class="grid_2">
<input type="text" name="email" id="email" value="<?php echo set_value('email'); ?>">
</div>
<div class="grid_4">
<?php echo form_error('email'); ?>
</div>
<div class="clear"></div>
<div class="grid_2">
<input type="submit" name="button" id="button" value="Submit">
</div>
</form>
Is there anything I'm doing wrong or is CI 2.1.0 to blame?