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 6350129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:45:16+00:00 2026-05-24T21:45:16+00:00

I have a controller and a view. I am trying to submit some details

  • 0

I have a controller and a view. I am trying to submit some details through a form, but when I submit it, no errors are displayed.

I am using only one controller to for 2 different types of users. The two users are –

  1. User
  2. Gym/Health Club Owner

And according to the $suertype, I have the same view being called but a different content being loaded.

This is my controller:

public function CreateProfile_Step2()
    {            
            $data['page_title'] = 'Create Profile (Step 2)';

            $loginid = $this->session->userdata('loginid');

            $this->load->model('profilemodel', 'profile');
            $userid = $this->profile->get_userid($loginid);

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

            $usertype = $this->profile->get_usertype($userid);
            $data['usertype'] = $usertype;

            if ($usertype == 'User') {
                $this->load->model('activitymodel', 'activity');
                $arr_activities = $this->activity->get_activities();
                $data['options'] = $arr_activities;
            }
            else if ($usertype == 'Gym/Health Club Owner') {
                $this->load->model('facilitymodel', 'facility');
                $arr_facility = $this->facility->get_facilities();
                $data['options'] = $arr_facility;
            }

            $config = array(
                'User'  =>  array(
                                array(
                                    'name'  => 'sex',
                                    'label' => 'Sex',
                                    'rules' => 'required'
                                )),
                'Gym/Health Club Owner' =>  array(
                                                array(
                                                    'name'  => 'website',
                                                    'label' => 'Website',
                                                    'rules' => 'prep_url'
                                                ),
                                                array(
                                                    'name'  => 'hours_of_operation',
                                                    'label' => 'Hours of Operation',
                                                    'rules' => 'required|numeric'
                                                ),
                                                array(
                                                    'name'  => 'membership_charges',
                                                    'label' => 'Membership Charges',
                                                    'rules' => 'required|numeric'
                                                ))
            );

            $this->form_validation->set_error_delimiters('<div class="error">', '</div>');

            $this->form_validation->set_rules($config);

            if ($usertype == 'User') {
                if ($this->form_validation->run('User') == FALSE) {
                    $this->load->view('create-profile-step-2', $data);
                }
                else {
                    $selected_options = $this->input->post('activities');
                    $this->activity->add_user_activities($userid, $selected_options);
                    $sex = $this->input->post('sex');
                    $this->profile->add_user_details($userid, $sex);
                    echo 'Profile Creation Completed!';
                }
            }
            else {
                if ($this->form_validation->run('Gym/Health Club Owner') == FALSE) {
                    $this->load->view('create-profile-step-2', $data);
                }
                else {
                    $selected_options = $this->input->post('facilities');
                    $this->facility->add_gym_facility($userid, $selected_options);
                    $website = $this->input->post('website');
                    $hours_of_operation = $this->input->post('hours_of_operation');
                    $membership_charges = $this->input->post('membership_charges');
                    $this->facility->add_gym_details($userid, $website, $hours_of_operation, $membership_charges);
                    echo 'Profile Creation Completed!';
                }
            }

    } 

This is my view:

    <?php include 'user/inc/header.php'; ?>

<div id="content" class="row twelvecol">
    <h1>Create Profile (Step 2 of 2)</h1>
    <h2>For <?php echo $usertype; ?></h2>
    <?php
        echo form_open('register/CreateProfile_Step2');
        if ($usertype == 'User') {
                echo form_label('Sex', 'sex');
                $options_sex = array(
                    'Male' => 'Male',
                    'Female' => 'Female'
                );
                echo form_dropdown('sex', $options_sex, 'male');
                $ctr = 1;
                echo form_label('Activities Interested In', 'activities');
                foreach($options->result() as $option)
                {
                    echo form_label($option->activity, 'activity-'.$ctr);
                    $arr_option = array(
                        'name'  => 'activities[]',
                        'id'    => 'activity-'.$ctr++,
                        'value' => $option->activity
                    );
                    echo form_checkbox($arr_option);
                }
        }
        elseif ($usertype == 'Gym/Health Club Owner')
        {
                echo form_label('Website', 'website');
                $arr_website = array(
                    'name' => 'website',
                    'id' => 'website',
                    'value' => set_value('website')
                );
                echo form_input($arr_website);
                echo form_label('Hours of Operation', 'hours_of_operation');
                $arr_hours = array(
                    'name' => 'hours_of_operation',
                    'id' => 'hours_of_operation',
                    'value' => set_value('hours_of_operation')
                );
                echo form_input($arr_hours);
                echo form_label('Membership Charges', 'membership_charges');
                $arr_charges = array(
                    'name' => 'membership_charges',
                    'id' => 'membership_charges',
                    'value' => set_value('membership_charges')
                );
                echo form_input($arr_charges);
                $ctr = 1;
                echo form_label('Facilities Available', 'facilities');
                foreach($options->result() as $option)
                {
                    echo form_label($option->facility, 'facility-'.$ctr);
                    $arr_option = array(
                        'name'  => 'facilities[]',
                        'id'    => 'facility-'.$ctr++,
                        'value' => $option->facility
                    );
                    echo form_checkbox($arr_option);
                }
        }
        echo "<br/><br/>";
        echo form_submit('submit', 'Create Profile');
        echo form_close();

        echo validation_errors();
    ?>

    <a href="<?php echo site_url(); ?>/register/CreateProfile_Step1">Return to previous step</a>

</div>

<?php include 'user/inc/footer.php'; ?>

It’s more likely some problem with the $config, because I have tried changing my code and used 2 separate controllers and views for the 2 cases.

  • 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-05-24T21:45:17+00:00Added an answer on May 24, 2026 at 9:45 pm

    Well, since no one answered my question. I was going through the code and found the errors myself. I had used the key ‘name’ in my configuration instead of ‘field’.

    INCORRECT CODE

    $config = array(
                    'User'  =>  array(
                                    array(
                                        'name'  => 'sex',
                                        'label' => 'Sex',
                                        'rules' => 'required'
                                    )),
                    'Gym/Health Club Owner' =>  array(
                                                    array(
                                                        'name'  => 'website',
                                                        'label' => 'Website',
                                                        'rules' => 'prep_url'
                                                    ),
                                                    array(
                                                        'name'  => 'hours_of_operation',
                                                        'label' => 'Hours of Operation',
                                                        'rules' => 'required|numeric'
                                                    ),
                                                    array(
                                                        'name'  => 'membership_charges',
                                                        'label' => 'Membership Charges',
                                                        'rules' => 'required|numeric'
                                                    ))
                );
    

    CORRECT CODE

    $config = array(
                    'User'  =>  array(
                                    array(
                                        'field'  => 'sex',
                                        'label' => 'Sex',
                                        'rules' => 'required'
                                    )),
                    'Gym/Health Club Owner' =>  array(
                                                    array(
                                                        'field'  => 'website',
                                                        'label' => 'Website',
                                                        'rules' => 'prep_url'
                                                    ),
                                                    array(
                                                        'field'  => 'hours_of_operation',
                                                        'label' => 'Hours of Operation',
                                                        'rules' => 'required|numeric'
                                                    ),
                                                    array(
                                                        'field'  => 'membership_charges',
                                                        'label' => 'Membership Charges',
                                                        'rules' => 'required|numeric'
                                                    ))
                );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to present a modal view controller. I have read the documentation,
I have a Java project that I'm trying to implement with a model-view-controller design.
I have a view controller that gets presented modally and changes some data that
Example: I have a view controller and get rid of it. But there's still
i've been trying to login through AJAX but somehow its not working. my controller
I have a partial view that is shared between two controllers and I'm trying
I have view controller, into the view i have put a table view, and
I have two view controller classes in my application delegate. I can change from
I have a view controller and I am intercepting the touches on links within
I have a view controller class that has to implement several protocols. Too keep

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.