简体   繁体   中英

one form data submit after new form open in codeigniter

I want help for form submit

Problem : when one form submit after new form open and i need also few data of first form data in second form how i can do this

$courseData['COURSE_ID']=$this->input->get_post( 'COURSE_ID');
$courseData['COURSE_NAME']=$this->input->get_post( 'COURSE_NAME');
$this->data['new_content']=$this->load->view('admin/unit/index',$courseData,true);

this code is try COURSE_ID and COURSE_NAME need in second form so what can i do ??

You can use flashdata, which is a part of the session library of codeigniter.

Flashdatas are session that is only kept for the next request. So the idea is to submit the form, keep the values you want in the flash data, then use it.

How flash data works: 1. Set flashdata 2. The flash data is available for the next refresh/request 3. It is now gone.

your code should be

function post_form()
{
    $this->session->set_flashdata('session_name', $this->input->post('name');
    //Your other codes
}

To access the flast data, simply use the code

<?php echo $this->session->flashdata('session_name'); ?>

You can read more about flashdatas in the user guide.

Goodluck meyt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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