2015-06-16 05:44 阅读 35


This is my view 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">
            <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'); ?>


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 )

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

4条回答 默认 最新

  • 已采纳
    dongren1986 dongren1986 2016-06-07 13:07

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

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

    Hope that helps

    点赞 评论 复制链接分享
  • douyun1860 douyun1860 2015-06-16 06:32
    if ( $this -> form_validation -> run() === FALSE )
            header('Location:');//your controller name

    Header Function


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


    点赞 评论 复制链接分享
  • duanpanhuo0618 duanpanhuo0618 2015-06-16 06:32

    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

    点赞 评论 复制链接分享
  • droos02800 droos02800 2015-06-16 06:35

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

    redirect(base_url().'controller/method', 'refresh');

    Refer CodeIgniter Docs

    点赞 评论 复制链接分享