Welcome Guest, Not a member yet? Register   Sign In
New is_unique form validation method NOT WORKING! [SOLVED]
#1

[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>&lt;?php echo $content; ?&gt;</p>

&lt;form name="member-registration" method="post" action="/member/register/"&gt;

    <div class="grid_2">
                                    
        <label for="email">Email: <span class="required">*</span></label>
                            
    </div>
                        
    <div class="grid_2">
                            
        &lt;input type="text" name="email" id="email" value="&lt;?php echo set_value('email'); ?&gt;"&gt;
                            
    </div>

    <div class="grid_4">
                        
        &lt;?php echo form_error('email'); ?&gt;
                            
    </div>

        <div class="clear"></div>
                        
    <div class="grid_2">
                        
        &lt;input type="submit" name="button" id="button" value="Submit"&gt;
                        
    </div>

&lt;/form&gt;

Is there anything I'm doing wrong or is CI 2.1.0 to blame?


Messages In This Thread
New is_unique form validation method NOT WORKING! [SOLVED] - by El Forum - 12-15-2011, 11:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB