This is opinion based question.
I am working in Codeigniter framework I have multi-step user registration form What i am doing is collecting all data in session array validating it and inserting in database.Till now all things are working fine but now i have added image upload form along with form i.e user will upload images while registration.Now i have doubt here i have two different Controllers for user registration[where i collect all form fields data in session array] and other controller for image upload. now what currently i am doing is saving user data in database and running update query to update user row for inserting images i.e when user register a unique id is assigned to it then by that unique id i am updating user data for inserting images[sounds ridiculous] but i want along with form data images name are also added to database at once now need of update query?? I hope my question is clear??All things are functional but i want it in prpoer way

//My view 
//image upload form
         <?php echo form_open_multipart('upload/do_upload', array('class' => 'upload-image-form'));?>
            <div class="form-inline">
              <div class="form-group">
                <input type="file" name="uploadfile[]" accept = "image/*" multiple = "multiple" size="20" /> <br />
              <button type="submit" value="upload" class="btn btn-sm btn-primary" name="submit">Upload files</button>

// user registration form 
     <form action="<?php echo base_url('Camping_register/register') ?>" method="post">
                        <h2>Camping <span class="red"><strong>Rent Details</strong></span></h2>
                        <label for="business_name">Business Name</label>
                        <input type="text" id="business_name" name="business_name" placeholder="enter your business name">
                        <label for="rental_description">Rental Description</label>
                        <textarea type="text" id="rental_description" name="rental_description"></textarea>
                        <button type="submit">REGISTER</button>
                        $message = $this->session->flashdata('msg');
                        echo '<div id="error_text">' . '<strong>'.$message .'</strong>'. '</div>';


//user registration form controller 
            // phase 2 data appended to session

        /* as we can see i added user input into session array 


//image upload controller

                "upload_path"       =>  $path,
                "allowed_types"     =>  "gif|jpg|png",
                "max_size"          =>  '2048',
                "encrypt_name"      => TRUE,


                //case success
                $data['upload_data'] = $this->upload->get_multi_upload_data();

                //let's call model function for inserting images into database

                 //$img['images'] = $this->Camping_model->insert_images($data);
                echo '<strong>'.'<p class = "bg-success">' . count($data['upload_data']) . 'File(s) successfully uploaded.</p>.'.'</strong>';

            } else {   
                // Output the errors
                $errors = array('error' => $this->upload->display_errors('<p class = "bg-danger">', '</p>'));              
                foreach($errors as $k => $error){
                    echo $error;


I need to know proper way of doing this so require suggestions how these things are applied in MVC
Plz help me also in this

// this is how model looks like 
   $session_data = $this->session->userdata('sessiondata');
        $user_id = $session_data['user_id'];

        $filePath = $upload_data['file_name'];
        $query = "UPDATE `tbl_usrs` set profile_picture='".$filePath."' where user_id='".$user_id."'";
       // $this->db->query($query,array($img));

    /* as we can see i am running update query this only
     * possible only when i have unique user_id but at the
      at time of registration no unique user_id is available as 
      he is not yet registrated **/

So what i want user data +images are inserted all at once in table ?? how can i achieve this ??
i will be very thankfull for any help

2 Years
Discussion Span
Last Post by diafol
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.