Welcome Guest, Not a member yet? Register   Sign In
Better structure?
#1

[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);

        }

    }
#2

[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.




Theme © iAndrew 2016 - Forum software by © MyBB