如何在CodeIgniter验证后重定向到视图页面中的锚标签

This is my view page.here I put anchor tag for Event view

<a href="#tab_3" data-toggle="tab">Events</a>
<div class="tab-pane" id="tab_3">
    <h3 class="box-title">Events</h3>
    <form role="form" id="EventForm"  action="<?echo base_url()?>home/submit_event" method="post">
        <div>
            <label>Event Name</label>
            <input id="event_name" name="e_name" type="text" style="margin-right:20px;width:174px;height:21px;margin-left:46px ;"  class="form-control event_form">
            <?php echo form_error('e_name'); ?>
        </div>
</div>

controller

Here the insertion after validation.if the validation run is false I need to redirect the anchor tag.but I don't know how this possible.Here I am doing redirect to index that's my home page

function submit_event()
{
    $this->form_validation->set_error_delimiters('<div style="color:#B94A48">', '</div>');

    $this->form_validation->set_rules('e_name', 'Event Name', 'required');
    if ( $this -> form_validation -> run() === FALSE )
    {
        $this->index();
        //redirect(base_url().'');

    }
    else
    {
        $event_name=$this->input->post('e_name');
        $event_data=array(
            'event_name'=>$event_name,
        );
        $this->home_model->insert_event($event_data);
    }
}

To redirect to an anchor in CI you should use redirect function like this :

redirect('/controller/function#anchor', 'refresh');

Hope that helps

if ( $this -> form_validation -> run() === FALSE )
    {
        header('Location: http://www.example.com/');//your controller name

    }

Header Function

or

if ( $this -> form_validation -> run() === FALSE )
    {
         redirect('/login/form/', 'refresh');//your controller name

    }

Redirect

codeigniter redirection can be achieved using the redirect method in the url helper. You can use this like this

redirect('/your controller/method', 'refresh');

Where 'your controller' is the controller that houses the method for the view page for new event add. And the 'method' is the method name inside the controller that loads the view. For reference go to this link codeigniter url helper

This is how you can do it. First load the URL helper, then call the redirect() method

$this->load->helper('url');
redirect(base_url().'controller/method', 'refresh');

Refer CodeIgniter Docs