Php flashdata在codeigniter中完全不工作
嗨,伙计们,我试过很多东西,比如Php flashdata在codeigniter中完全不工作,php,codeigniter,Php,Codeigniter,嗨,伙计们,我试过很多东西,比如 $this->session->keep_flashdata(); $this->session->set_flashdata(); 但是在重定向时启用加载消息,我将在下面发布我的代码,看看并帮助我解决这个问题 控制器: $params = array( 'full_name' => $this->input->post('full_name'), 'father
$this->session->keep_flashdata();
$this->session->set_flashdata();
但是在重定向时启用加载消息,我将在下面发布我的代码,看看并帮助我解决这个问题
控制器:
$params = array(
'full_name' => $this->input->post('full_name'),
'father_name' => $this->input->post('father_name'),
'email' => $this->input->post('email'),
'phone' => $this->input->post('phone'),
'password' => $this->input->post('password'),
'cnic_no' => $this->input->post('cnic_no'),
'manager' => $this->input->post('manager'),
'department_id' => $this->input->post('department_id'),
'created_by' => $_SESSION['user_id'],
'position' => $this->input->post('position'),
'created_at' => $now,
);
$this->Maintainer_basic_model->insert($params);
$this->session->set_flashdata('success', 'Maintainer added successfully');
redirect('maintainer_basic/index');
<?php if($message = $this->session->flashdata('success')): ?>
<div class="row">
<div class="col-md-12 form-group">
<div class="alert-success alert">
<?php echo $message; ?>
</div>
</div>
</div>
<?php endif ?>
查看:
$params = array(
'full_name' => $this->input->post('full_name'),
'father_name' => $this->input->post('father_name'),
'email' => $this->input->post('email'),
'phone' => $this->input->post('phone'),
'password' => $this->input->post('password'),
'cnic_no' => $this->input->post('cnic_no'),
'manager' => $this->input->post('manager'),
'department_id' => $this->input->post('department_id'),
'created_by' => $_SESSION['user_id'],
'position' => $this->input->post('position'),
'created_at' => $now,
);
$this->Maintainer_basic_model->insert($params);
$this->session->set_flashdata('success', 'Maintainer added successfully');
redirect('maintainer_basic/index');
<?php if($message = $this->session->flashdata('success')): ?>
<div class="row">
<div class="col-md-12 form-group">
<div class="alert-success alert">
<?php echo $message; ?>
</div>
</div>
</div>
<?php endif ?>
根据您给定的代码,我认为您没有在config/autoload.php中加载会话库 检查下面的代码以了解情况
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$autoload['packages'] = array();
$autoload['libraries'] = array("session","form_validation","database");
$autoload['drivers'] = array();
$autoload['helper'] = array('url','path','form');
$autoload['config'] = array();
$autoload['language'] = array();
$autoload['model'] = array();
just do@devsiodera未工作$message
不作为会话变量存在。只需回显$this->session->flashdata('success')
。您正在设置一个键->值对,其中flashdata键为success
,值为Maintainer added successfulyy
@javierlaroulet我仅用$this->session->flashdata('success')进行了尝试但是仍然不工作您完全正确会话未包含在autoload.php中我已经包含了它,但再次尝试,但它仍然不工作实际上
此条件没有实现…是的,在编程过程中,您将始终尝试100%集中精力