在 Codeigniter 中提交或更新任何内容后不显示更新的数据
Posted
技术标签:
【中文标题】在 Codeigniter 中提交或更新任何内容后不显示更新的数据【英文标题】:Not Showing updated data after submitting or updating anything in Codeigniter 【发布时间】:2019-07-22 09:08:28 【问题描述】:我最近将我的网站转移到另一台服务器。除了一件事,一切都正常工作。当我在我的网站上提交或更新任何数据时,它不会显示更新的数据。无论我重新提交或更新数据多少次,它总是显示旧数据。只有当我点击浏览器上的重新加载按钮时,它才会显示更新的数据。
注意:它在我的数据库上完美运行。我的旧网站运行良好。我在每个控制器上使用 redirect() 刷新
这是我的 config.php
<?php if(!defined('BASEPATH'))exit('No direct script access allowed');
$config['base_url']='https://eshaplasticbd.net/';
$config['index_page']='';
$config['uri_protocol']='AUTO';
$config['url_suffix']='';
$config['language']='english'; $config['charset']='UTF-8';
$config['enable_hooks']=FALSE;
$config['subclass_prefix']='MY_';
$config['permitted_uri_chars']='a-z 0-9~%.:_\-';
$config['allow_get_array']=TRUE;
$config['enable_query_strings']=FALSE;
$config['controller_trigger']='c';
$config['function_trigger']='m'; $config['directory_trigger']='d';
$config['log_threshold']=0; $config['log_path']='';
$config['log_date_format']='Y-m-d H:i:s';
$config['cache_path']='';
$config['encryption_key']='bds@urcing123';
$config['sess_cookie_name']='ci_session';
$config['sess_expiration']=7200;
$config['sess_expire_on_close']=FALSE;
$config['sess_encrypt_cookie']=FALSE;
$config['sess_use_database']=TRUE;
$config['sess_table_name']='ci_sessions';
$config['sess_match_ip']=FALSE;
$config['sess_match_useragent']=TRUE;
$config['sess_time_to_update']=300; $config['cookie_prefix']="";
$config['cookie_domain']=""; $config['cookie_path']="/";
$config['cookie_secure']=FALSE;
$config['global_xss_filtering']=FALSE;
$config['csrf_protection']=FALSE;
$config['csrf_token_name']='csrf_test_name';
$config['csrf_cookie_name']='csrf_cookie_name';
$config['csrf_expire']=7200; $config['compress_output']=FALSE;
$config['time_reference']='local';
$config['rewrite_short_tags']=FALSE; $config['proxy_ips']='';
$config['sess_save_path'] = 'ci_sessions';
$config['sess_regenerate_destroy'] = FALSE;
autoload.php 文件在这里:
$autoload['helper'] = array('url', 'form','file');
$autoload['config'] = array();
$autoload['language'] = array();
$autoload['model'] = array('log_model');
router.php 文件在这里:
<?php if(!defined('BASEPATH'))exit('No direct script access allowed');
if ($_SERVER["SERVER_NAME"]!=='eshaplasticbd.net') die ("License ERROR!!!"); else $route['default_controller'] = 'main';
$route['404_override']='';
控制器代码示例:
<?php session_start(); ?>
<?php if(!defined('BASEPATH'))exit('No direct script access allowed');
class main extends CI_Controllerfunction __construct()
parent::__construct();
function index()$data=array();
if(!$this->session->userdata('is_logged_in'))
redirect('index.php/main/login','refresh');exit;
if($this->session->userdata('org_id'))$this->load->model('config_model');$uid=$this->session->userdata('user_details')->id;$data['btns']=$this->config_model->get_btns('MAIN',$uid);$data['err']="";
if(count($data['btns'])==1)redirect($data['btns'][0]->btn_url,'refresh');exit;if(count($data['btns'])==0)$data['err']="NO PERMISSION ASSIGNED IN MAIN!!!";$data['main_container']='main';
if($this->session->userdata('user_details')->role_id =='2')$data['main_container']='hr/main';if($this->session->userdata('user_details')->role_id=='3')
redirect('index.php/hrgroup/attendance','refresh');exit;
if($this->session->userdata('user_details')->role_id =='s_2')
redirect('index.php/salesgroup/sales/sales_list','refresh');exit;
if($this->session->userdata('user_details')->role_id =='stock_user')
redirect('index.php/salesgroup/sales/current_stock','refresh');exit;
if($this->session->userdata('user_details')->role_id =='invoice_user')
redirect('index.php/salesgroup/sales/new_invoice','refresh');exit;
if($this->session->userdata('user_details')->role_id =='purchase_entry')
redirect('index.php/purchasegroup/purchase','refresh');exit;$this->load->view('template',$data);elseredirect('index.php/setting/','refresh');exit;
【问题讨论】:
【参考方案1】:您可以在控制器方法上成功查询更新后使用redirect('routename');
。
【讨论】:
以上是关于在 Codeigniter 中提交或更新任何内容后不显示更新的数据的主要内容,如果未能解决你的问题,请参考以下文章