Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9160687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:47:49+00:00 2026-06-17T13:47:49+00:00

im trying to write a code where a form will store all of its

  • 0

im trying to write a code where a form will store all of its values inside session variables when the submit button is pressed and go to the next page where there is another form waiting to be filled up. when the submit button for the form in page 2 is pressed the variables will be stored in a session then the contents of the session variables/array will be inserted in the database. and i seem to be having problems

Summary:

  1. Page 1 – User fills up form and the variables will be stored in a session array upon submit

  2. Page 2 – user fills up another form and the variables will be stored in a session array upon submit

  3. the session variables in page 1 and 2 will be inserted in the database

here is my code:

controller(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");    
            }
        }

the problem with my code is that the session variables for page 2(public function m2()) is the only one that gets inserted in the database.
is there a way to fix this?

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:47:50+00:00Added an answer on June 17, 2026 at 1:47 pm

    In the first function (M1)

    set your newdata in this way

    $this->session->set_userdata('newdata', $newdata);
    

    In second function (M2)

        public function m2()
        {
            if(isset($_POST['m2']))
            {
                $nature_complaint = $this->input->post("nature_complaint");
    
                $newdata = array();
                $newdata = $this->session->userdata('newdata');
                $newdata['nature_complaint'] = $nature_complaint;
    
                $this->session->set_userdata('newdata', $newdata);
    
                $this->db->insert('myself', $newdata); 
                redirect(base_url() . "site/cmain/m/3");    
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm trying to write an interactive form, where clicking a radio button will
I'm trying to write code in my controller that when run, will create a
I'm trying to write code that will load an image from a resource, and
I am trying to write some code that will generate accurate .proto files from
I'm trying to write some JavaScript for my website that will select all the
I'm trying to write a piece of code that will run through a table
I am trying to write a PHP script that will create an HTML form
I am trying to write a universal code for AJAX. I will show what
I'm trying to write a program that will factor any trinomial of the form
I'm trying to write a greasemonkey script that will automatically perform the Steam store

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.