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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:27:32+00:00 2026-06-10T09:27:32+00:00

About a week ago i started experimenting with CodeIngiter, because i want to learn

  • 0

About a week ago i started experimenting with CodeIngiter, because i want to learn OOP. I thought i was on the right track, but now i begin to doubt that. The reason is, i have a controller for Members, which is becoming quite a large file. This is because i want my urls to be like members/login , members/register etc.

Here is my controller:

<?php
class Members extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->model('users');
    }
    public function index()
    {
    }
    public function register()
    {
        $this->load->helper(array(
            'form',
            'recaptcha'
        ));
        $this->load->library('form_validation');
        $data['title']       = "Register a free account - Become an Author";
        $data['titlesucces'] = "Thanks for registering";
        $this->form_validation->set_rules('fname', 'First name', 'required');
        $this->form_validation->set_rules('lname', 'Last name', 'required');
        $this->form_validation->set_rules('password', 'Password', 'required');
        $this->form_validation->set_rules('passwordconf', 'Password Confirmation', 'required');
        $this->form_validation->set_rules('email', 'Emailaddress', 'required|is_unique[users.email]|valid_email');
        $this->form_validation->set_rules('recaptcha_challenge_field', 'Captcha', 'required|recaptcha_matches');
        if (!$this->form_validation->run()) {
            $this->load->view('header', $data);
            $this->load->view('register', $data);
        } else {
            $this->users->register_new_member();
            $this->load->view('register_succes', $data);
        }
    }
    public function login()
    {
        $data['title'] = "Login";
        $data['fail']  = "";
        $this->load->helper('form');
        $this->load->library('form_validation');
        $this->form_validation->set_rules('email', 'Emailaddres', 'required');
        $this->form_validation->set_rules('password', 'Password', 'required');
        if (!$this->form_validation->run()) {
            $this->load->view('login', $data);
        } else {
            if ($this->users->do_login($this->input->post('email'), $this->input->post('password'))) {
                $this->load->view('login', $data);
            } else {
                $data['fail'] = "Emailaddress or password is incorrect";
                $this->load->view('login', $data);
            }
        }
    }
    public function logout()
    {
        $this->session->sess_destroy();
        redirect('/members/login/', 'refresh');
    }
    public function addarticle()
    {
        if ($this->users->logged_in()) {
            $this->load->helper('form');
            $this->load->library('form_validation');
            $this->form_validation->set_rules('title', 'Title', 'required|max_length[200]|min_length[10]');
            $this->form_validation->set_rules('intro', 'Intro', 'required|min_length[40]|max_length[50]');
            $this->form_validation->set_rules('cat', 'Category', 'required');
            $this->form_validation->set_rules('body', 'Article', 'required|min_length[3000]|link_check');

            $this->load->model('categories');
            $data['title'] = "Add a new article";
            $data['cats']  = $this->categories->get_all_categories();
            if (!$this->form_validation->run()) {
                $this->load->view('addarticle', $data);
            } else {
                $this->load->model('articles');
                $this->articles->add_new_article();
                $this->load->view('welcome');
            }
        } else {
            redirect('/members/login/', 'refresh');
        }
    }

}
?>

As you can see its quite a big file already, but it will only get bigger. Now my question to you guys is: is this still the right MVC way or am i doing something wrong?

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-10T09:27:33+00:00Added an answer on June 10, 2026 at 9:27 am

    You are doing completelly right things, and this file isn’t big anough yet, and I doubt it will be. I’ve programmed on CodeIgniter – great and light-weight FW, and there is a cool MVC model/pattern workarounds. So just keep going.

    Another thing while Your file/controller didn’t achive 1000-1500 lines of code do not bother Your-self with this question.

    The MVC is not actually what Your controller contains, rather than whole bunch of things Models(DB Queries, Herlper Functions), Views(Templates/GUI) and Controller(Logic) – keep that in mind and do not worry about anything at this point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I started to really sit down and learn PHP about a week ago, so
I've just started learning Java (about a week ago) and the last few days
I started Objective-C programming about a week ago and am stuck on creating a
My disclaimer here is that I started teaching myself C++ about a week ago
I checked some files out for edit about a week ago and I want
i've started WP7 development about a week ago (and programming in general) and I've
For about 3 week ago I started looking for the first time in to
I started using Thrift about a week ago. I got the latest source from
I just started learning Python about a week ago. I've made considerable progress thanks
About a week ago I have started a online course compilers at coursera.org. Today

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.