CodeIgniter Forums

Full Version: Better structure?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]MMCCQQ[/eluser]
hI!

i started a new project. I need tips to make better Web App about structure.

i made this

SignUp - Controller

Code:
function Signup()
    {


        if ($_POST['password'])
        {
            if(!$_POST['password'] == $_POST['password2']){
                
                $info['msg'] = 'Please enter the same password twice';
                $contents['main'] = $this->load->view('index/signup_page',$info);
                
            }else{


            $this->db->where('email', $_POST['email']);
            $query = $this->db->get('members');

            if ($query->num_rows() > 0)
            {


                $info['msg'] = $_POST['email'].'is registered in our database.';
                $contents['main'] = $this->load->view('index/signup_page',$info);


            }
            else
            {
                

                if ($this->db->insert('members', $_POST))
                {


                   redirect('/'.$_POST['username']);

                }
                else
                {


                   $info['msg'] = 'An error occurred, Try Again.';
                    $contents['main'] = $this->load->view('white_page', $info);
                }

            }

}
        }
        else
        {


           $info['msg'] = false;
            $contents['main'] = $this->load->view('index/signup_page', $info);

        }

    }

El Forum

[eluser]wiredesignz[/eluser]
I don't see any real CodeIgniter code in there Tongue

TIPs:
Use the CI_Validation library.
Use Models.

Don't repeat yourself (DRY) by using the same code in different places.