Welcome Guest, Not a member yet? Register   Sign In
accessing form data
#1

[eluser]dwlamb[/eluser]
I am going sound exactly what I am: A newbie to CI

I've done the Form Validation tutorial and read the Form Helper documentation. But I have nagging question: How do I access the form data once validation is successful?

This is my code for creating a new user:
Code:
function create_user() {
    $this->load->helper(array('form', 'url'));
    $this->load->library('form_validation');
    $this->form_validation->set_rules('e-mail', 'E-mail address', 'required');
    $this->form_validation->set_rules('pwd', 'Password', 'required|min_length[5]|matches[pwd2]');
    $this->form_validation->set_rules('pwd2', 'Password Confirmation', 'required');
    $data['form_open'] = form_open('welcome/create_user');
    if ($this->form_validation->run() == FALSE) {
        $this->load->view('welcome_register', $data);
    }
    else {
        $this->form_validation->set_rules('pwd', 'Password', 'trim|required|matches[pwd2]|md5|xss_clean');
        $this->form_validation->set_rules('pwd2', 'Password Confirmation', 'trim|required');
        $this->form_validation->set_rules('e-mail', 'Email', 'trim|required|valid_email|xss_clean');
        print_r('$_POST');die();
        $this->simpleloginsecure->create('[email protected]', '$userpass!');
        echo 'user created';
    }
}
Once my data validates, I wish to process the data for storing it. I put the print_r('$_POST');die(); in there to see if the data is there and it returns not even as an empty array.

As you see in this code, eventually I wish to pass variable of user e-mail and password to a function that will create the user in the database.




Theme © iAndrew 2016 - Forum software by © MyBB