Welcome Guest, Not a member yet? Register   Sign In
login system, how to go from controller to view to model
#6

[eluser]jvittetoe[/eluser]
alright. ive gone through and read the user guide on validation and kinda just kept going. what im trying to do now is a registration form. im trying to submit the form inputs into my useraccounts table. here are my files.

signUp.php
Code:
<?php

class SignUp extends Controller {

    function SignUp(){
        
        parent::Controller();
    }
    
    function index(){
        
        $this->load->helper( array('url', 'form') );
        $this->load->library('validation');
        
        $rules['firstname']       ="trim|required|min_length[1]|max_length[20]";
        $rules['lastname']      ="trim|required|min_length[1]|max_length[20]";
        $rules['emailaddress']      ="trim|required|valid_email";
        $rules['username']      ="trim|required|min_length[1]|max_length[20]|xss_clean";
        $rules['password']    ="trim|required|matches[passconf]|md5";
        $rules['passconf']    ="trim|required";
        
        $this->validation->set_rules($rules);
        
        $fields['firstname']    ='firstname';
        $fields['lastname']    ='lastname';
        $fields['emailaddress']       ='emailaddress';
        $fields['username']       ='username';
        $fields['password']    ='password';
        $fields['passconf']    ='passconf';
        
        $this->validation->set_fields($fields);
        
        if($this->validation->run() == FALSE){
            $this->load->view('signUp');
        } else {
            $this->load->model('actSignUp', '', TRUE);
            $query = $this->actSignUp->addUser(
                $this->input->post('firstname'),
                $this->input->post('lastname'),
                $this->input->post('emailaddress'),
                $this->input->post('username'),
                $this->input->post('password')
                );
                
            if($query){
                $this->load->view('dashboard');
            } else {
                $this->load->view('signUp');
            }
            
        }
    }
}

?>

actsignup.php
Code:
<?php

class actSignUp extends Model {
    
    function actSignUp(){
    
        parent::Model();
    }
    
    function addUser(){
        
        $data = array(
            
            'firstname' => $_POST['firstname'],
            'lastname' => $_POST['lastname'],
            'emailaddress' => $_POST['emailaddress'],
            'username' => $_POST['username'],
            'password' => $_POST['password']
            
            );
            
        $this->db->insert('useraccounts', $data);
        
    }
}

?>

when i submit the form on the signUp page, it reloads the page and changes my password field from '***' to '********************************' (32) characters. is there something going wrong with md5?


Messages In This Thread
login system, how to go from controller to view to model - by El Forum - 06-25-2007, 11:46 PM



Theme © iAndrew 2016 - Forum software by © MyBB