Welcome Guest, Not a member yet? Register   Sign In
Problem with form validation
#1

[eluser]Aniket Pant[/eluser]
Form validation is not working in one of the pages. Rest of the pages are working fine.

This is my controller:
Code:
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!';
                    }
                }
                
        }


Messages In This Thread
Problem with form validation - by El Forum - 08-09-2011, 11:59 PM
Problem with form validation - by El Forum - 08-09-2011, 11:59 PM
Problem with form validation - by El Forum - 08-10-2011, 12:26 AM
Problem with form validation - by El Forum - 08-10-2011, 12:29 AM
Problem with form validation - by El Forum - 08-10-2011, 01:19 AM
Problem with form validation - by El Forum - 08-10-2011, 01:25 AM
Problem with form validation - by El Forum - 08-10-2011, 04:23 AM
Problem with form validation - by El Forum - 08-10-2011, 04:25 AM
Problem with form validation - by El Forum - 08-10-2011, 08:36 AM
Problem with form validation - by El Forum - 08-10-2011, 02:51 PM
Problem with form validation - by El Forum - 08-10-2011, 08:14 PM
Problem with form validation - by El Forum - 08-10-2011, 11:36 PM
Problem with form validation - by El Forum - 08-10-2011, 11:37 PM
Problem with form validation - by El Forum - 08-11-2011, 12:02 AM
Problem with form validation - by El Forum - 08-11-2011, 12:05 AM
Problem with form validation - by El Forum - 08-11-2011, 12:13 AM
Problem with form validation - by El Forum - 08-11-2011, 12:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB