李文凯老师 关于TP添加后跳转的问题

老师您好,这样的,我想在添加成功后返回index,但是不知道redirect应该放在哪里。恳请老师或者各位高手回答
复制代码
  1.         public function insert() {
  2.         $form    =    M("user");
  3.         if($vo = $form->create()) {
  4.             $form->password = md5($form->password);
  5.             $list = $form->add();
  6.             if($list) {
  7.                 $this->success("插入成功");
  8.                 //$this->redirect('index');
  9.             } else {
  10.                 $this->error("插入失败");
  11.                 }
  12.             } else {
  13.                 $this->error($form->geterror());
  14.                 }
  15.         
  16.     }


作者: winwayz   发布时间: 2011-09-15

            public function insert() {
            $form    =    M("user");
            if($vo = $form->create()) {
                $form->password = md5($form->password);
                $list = $form->add();
                if($list) {
                   //$this->success("插入成功");
$this->redirect('index');
                } else {
                    $this->error("插入失败");
                    }
                } else {
                    $this->error($form->geterror());
                    }
          

        }

[ 此帖被赤道雨季在2011-09-17 09:40重新编辑 ]

作者: 赤道雨季   发布时间: 2011-09-17