由于某些原因,我在提交表单后尝试重定向时无法访问$ id。我可以在if语句之外访问$ id,但似乎我得到了一个空值为$ id的重定向。有什么建议吗?
function edit_user($id = NULL){
if(!$id)
{
show_404();
}
if($this->input->post('submit'))
{
$this->form_validation->set_rules('username','Nombre de usuario','required');
$this->form_validation->set_rules('password','Contraseña','required');
$this->form_validation->set_rules('checkpassword','Reingrese contraseña','required|matches[password]');
$this->form_validation->set_message('required','El Campo %s es obligatorio');
$this->form_validation->set_message('matches','Las contraseñas ingresadas no coinciden');
if($this->form_validation->run() != FALSE){
$this->Users_model->edit_users();
$mensaje = "Usuario editado correctamente";
redirect(base_url().'users/edit_user/'.$id, 301);
}
else
{
redirect(base_url().'users/edit_user/'.$id, 301);
}
}
$query = $this->Users_model->getuserid($id);
if($query == false){
$data = array('title'=>'Admin ::LxFPanamá::',
'content'=>'users/add_users_view',
'id'=>$id);
}else{
$data = array('title'=>'Admin ::LxFPanamá::',
'content'=>'users/edit_users_view',
'id'=> $query->id,
'login'=> $query->login,
'password'=> $query->password);
}
$this->load->view('themes/'.$this->config->item('theme_front').'.php', $data);
}
答案 0 :(得分:0)
尝试使用flashdata
$this->session->set_flashdata('item',$i);
redirect(base_url().'users/edit_user','refresh',301);
获取价值
$this->session->flashdata('item');