How can i use same form for insert and update in php?

I'm trying to use a single form for inserting a new data and updating the value of an existing data.I have no trouble displaying the form, fetching the data and updating it, but when I'm trying to insert a new data, the form does not appear. Here's my view

label for="short_name" class="control-label">Inclusions

My model

 public function insert($data = array())
    {
        if (!empty($data)) {
            $this->db->insert('packages', $data);

            return $this->db->insert_id();
        }
        return false;
    }
public function edit($id)
    {
        $query = $this->db->get_where("packages", array('id' => $id));

        return $query->row();
    }

    public function update($data, $id)
    {
        return $this->db->update("packages", $data, array('id' => $id));
    }

And then Controller

public function insert_package()
    {
        $packageData = array();

        // If add request is submitted
        if ($this->input->post('packageData')) {
            // Form field validation rules
            $this->form_validation->set_rules('title', 'Package Name', 'required');
            $this->form_validation->set_rules('tour_location', 'Inclusions', 'trim');
            $this->form_validation->set_rules('description', 'Description', 'trim|required');
            $this->form_validation->set_rules('cost', 'Price', 'required');
            $this->form_validation->set_rules('status', 'Status', 'required');
            // $this->form_validation->set_rules('image', 'Images', 'required');

            // Validate submitted form data
            if ($this->form_validation->run() == true) {
                $ori_filename = $_FILES['image']['name'];
                $update_image = time() . "" . str_replace(' ', '-', $ori_filename);
                $config = [
                    'upload_path' => './images',
                    'allowed_types' => 'gif|jpg|png',
                    'file_name' => $update_image,
                ];

                $this->load->library('upload', $config);

                if (!$this->upload->do_upload('image')) {
                    $error = array('error' => $this->upload->display_errors());
                    $this->load->view(base_url('admin/packages'), $error);
                } else {

                    $image = $this->upload->data('file_name');
                    $packageData = array(
                        'title' => $this->input->post('title'),
                        'tour_location' => $this->input->post(htmlentities('tour_location')),
                        'description' => $this->input->post(htmlentities('description')),
                        'cost' => $this->input->post('cost'),
                        'status' => $this->input->post('status'),
                        'upload_path' => $image
                    );
                    $img = new Admin_model;
                    // Insert member data
                    $img->insert($packageData);
                    $this->session->set_flashdata('status', 'Package InsertedSuccesfully');
                    redirect(base_url('admin/packages'));
                }
            }
        }

        $data['title'] = 'Add Package';

        $this->load->view('../admin/template/admin_header');
        $this->load->view('../admin/template/admin_topnav');
        $this->load->view('../admin/template/admin_sidebar');
        $this->load->view('../admin/packages/manage_package', $data);
        $this->load->view('../admin/template/admin_footer');
    }

    public function edit_package($id)
    {
        $data['title'] = 'Update Package';

        $this->load->view('../admin/template/admin_header');
        $package = new Admin_model;
        $data['packages'] = $package->edit($id);
        $this->load->view('../admin/template/admin_topnav');
        $this->load->view('../admin/template/admin_sidebar');
        $this->load->view('../admin/packages/manage_package', $data);
        $this->load->view('../admin/template/admin_footer');
    }

    public function update_package($id)
    {
        $this->form_validation->set_rules('title', 'Package Name', 'required');
        $this->form_validation->set_rules('tour_location', 'Inclusions', 'trim');
        $this->form_validation->set_rules('description', 'Description', 'trim|required');
        $this->form_validation->set_rules('cost', 'Price', 'required');
        $this->form_validation->set_rules('status', 'Status', 'required');

        if ($this->form_validation->run() == true) {
            $current_image = $this->input->post('current_image');
            $new_image = $_FILES['image']['name'];

            if ($new_image == TRUE) {

                $update_image = time() . "-" . str_replace(' ', '-', $_FILES['image']['name']);
                $config = [
                    'upload_path' => './images',
                    'allowed_types' => 'gif|jpg|png',
                    'file_name' => $update_image,
                ];

                $this->load->library('upload', $config);

                if (!$this->upload->do_upload('image')) {
                    if (file_exists('./images' . $current_image)) {
                        unlink('./images' . $current_image);
                    }
                }
            } else {
                $update_image = $current_image;
            }

            $packageData = array(
                'title' => $this->input->post('title'),
                'tour_location' => $this->input->post(htmlentities('tour_location')),
                'description' => $this->input->post(htmlentities('description')),
                'cost' => $this->input->post('cost'),
                'status' => $this->input->post('status'),
                'upload_path' => $update_image
            );
            
            $this->Admin_model->update($packageData, $id);
            $this->session->set_flashdata('status', 'Package InsertedSuccesfully');
            redirect(base_url('admin/packages/'));
        } else {
            return $this->edit_package($id);
        }
    }

I found a question here and an answer and suggestion but I can't still solve my problem.

How do you use same form for add and edit in PHP?

php) with the same form controls filled with data from mysql..
If action is edit then you can set $_GET['action'] parameter as edit on page auditplanentry. php . ... .
You can use a hidden text field where you mention your action .. Either "new" or " update" .. ... .
Are you familiar with INSERT... UPDATE syntax?.

Can we use insert in place of update?

No. Insert will only create a new row.

How to insert form data into database using PHP?

Complete Steps to Design Project:.
Start XAMPP Server..
Open localhost/phpmyadmin in your web browser..
Create database of name staff and table of name college..
Write HTML and PHP code in your Notepad in a particular folder..
Submit data through HTML Form..
Verify the results..

How to insert data with submit button in PHP?

Insert Data Into a Database using HTML form "Submit. php" file connects to a database, and PHP $ _POST variable receives the value from the form. Then, mysqli_query() function executes INSERT INTO statement, and a new record will be added to the "contact" table. submit.