送信ボタンが押されたときにフォームがすべての値をセッション変数内に保存し、入力を待っている別のフォームがある次のページに移動するコードを作成しようとしています。ページ 2 のフォームの送信ボタンが押されると、変数がセッションに保存され、セッション変数/配列の内容がデータベースに挿入されます。そして、私は問題を抱えているようです
概要:
ページ 1 - ユーザーがフォームに入力すると、送信時に変数がセッション配列に格納されます
ページ 2 - ユーザーが別のフォームに入力すると、送信時に変数がセッション配列に格納されます
ページ 1 と 2 のセッション変数がデータベースに挿入されます
ここに私のコードがあります:
コントローラー(site.php)
public function m1()
{
if(isset($_POST['m1']))
{
$suffix = $this->input->post("suffix");
$fn = $this->input->post("fn");
$mn = $this->input->post("mn");
$ln = $this->input->post("ln");
$nickname = $this->input->post("nickname");
$sex = $this->input->post("sex");
$bday = $this->input->post("bday");
$street = $this->input->post("street");
$city = $this->input->post("city");
$province = $this->input->post("province");
$region = $this->input->post("region");
$landline = $this->input->post("landline");
$cellphone = $this->input->post("cellphone");
$email = $this->input->post("email");
$edu_level = $this->input->post("edu_level");
$course = $this->input->post("course");
$school_name = $this->input->post("school_name");
$school_address = $this->input->post("school_address");
$school_province = $this->input->post("school_province");
$school_city = $this->input->post("school_city");
$school_region = $this->input->post("school_region");
$newdata = array('suffix'=>$suffix,
'fn'=>$fn,
'mn'=>$mn,
'ln'=>$ln,
'nickname'=>$nickname,
'sex'=>$sex,
'bday'=>$bday,
'street'=>$street,
'city'=>$city,
'province'=>$province,
'region'=>$region,
'landline'=>$landline,
'cellphone'=>$cellphone,
'email'=>$email,
'edu_level'=>$edu_level,
'course'=>$course,
'school_name'=>$school_name,
'school_address'=>$school_address,
'school_province'=>$school_province,
'school_city'=>$school_city,
'school_region'=>$school_region,
);
$this->session->set_userdata($newdata);
redirect(base_url() . "site/cmain/m/2");
}
}
public function m2()
{
if(isset($_POST['m2']))
{
$nature_complaint = $this->input->post("nature_complaint");
$newdata = array('nature_complaint'=>$nature_complaint);
$this->session->set_userdata($newdata);
$this->db->insert('myself', $newdata);
redirect(base_url() . "site/cmain/m/3");
}
}
私のコードの問題は、ページ 2 (パブリック関数 m2()) のセッション変数がデータベースに挿入される唯一のものであることです。これを修正する方法はありますか?
ありがとう