简体   繁体   English

在杂货店插入之前重定向页面

[英]redirect page before insert in grocery crud

I want to redirect page before insert when some condition happened and the page reloaded successfully in firebug. 当某些情况发生并且页面在Firebug中成功重新加载时,我想在插入之前重定向页面。

my code : 我的代码:

$crud->callback_before_insert(array($this,'callback_function'));

the function : 功能 :

$getRow1= $this->db->where('nationalityID',$getRow->id)->get('table_name')->row();

$data = array('courseID'=>$courseID,'userID'=>$getRow1->id);
$insert= $this->db->insert('table_name1',$data);

if($insert) {
    $newlink =  base_url()."admin/control_trainee_courses/data/". $courseID;
    echo "<script>" . "window.location = '$newlink';</script>";

    // or using   redirect(base_url()."index.php/admin/control_trainee_courses/data/".$courseID ;
}

please help. 请帮忙。

echo ("<SCRIPT LANGUAGE='JavaScript'>top.location.href='/index.php/';</SCRIPT>");
exit();

It will end code execution, so insert will not occur. 它将结束代码执行,因此不会发生插入。

Also, make sure that you are redirecting to the same domain, or browser will prevent redirection. 另外,请确保您要重定向到同一域,否则浏览器将阻止重定向。

您可以使用URl帮助程序和重定向

redirect(base_url(), 'refresh');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM