How to Validate an Email Duplicate Entry in Codeigniter

// Step 1: Load the form validation library in your controller

// Step 2: Set the validation rules for the email field in your controller
$this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[]');

// Step 3: Check if the form validation is successful
if ($this->form_validation->run() == FALSE) {
    // Validation failed, handle errors (e.g., display error messages)
} else {
    // Validation passed, proceed with your logic to insert the data
    $data = array(
        'email' => $this->input->post('email'),
        // Add other fields as needed

    // Your database insertion logic goes here

    // Redirect or show success message as needed

Make sure to replace '' with the actual table and field name in your database. Also, customize the controller, view, model names, and other details based on your application structure.