Welcome Guest, Not a member yet? Register   Sign In
How to insert into Database the Prepped Data from the Validation Class
#1

[eluser]Unknown[/eluser]
I am doing a simple user registration. I prepped the data along with the validation rules just as the documentation stated.
Code:
this->form_validation->set_rules('first_name', 'First name', 'trim|required|max_length[30]|xss_clean');
        $this->form_validation->set_rules('last_name', 'Last name', 'trim|required|max_length[30]|xss_clean');
        
        $this->form_validation->set_rules('password', 'Password', 'required|min_length[7]|max_length[15]|matches[password_conf]|xss_clean|md5');
        $this->form_validation->set_rules('password_conf', 'Password confirmation', 'required|max_length[15]');
        
        //**enforce stronger passwords
        $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email|max_length[50]|xss_clean|callback_is_id_unique');
        $this->form_validation->set_rules('phone', 'Phone', 'trim|required|numeric|max_length[10]|xss_clean');

Now I am ready to insert the info into the database. something like this.
Code:
$data = array(
                'email' => 'email???',
                'password' => 'password???',
                'first_name' => 'first_name???',
        'registration_date' => now(),
                'last_name' => 'last_name????',
                'phone' => 'phone????',
        
            );
            $this->db->insert('tblcustomers', $data);
I need to insert the prepped data instead of just the POST data. How do I go about doing this???

Any helo will be greatly appreciated. Thanks!
#2

[eluser]amites[/eluser]
as I recall the POST data is modified by the form_validation class
#3

[eluser]phpwebdev[/eluser]
[quote author="eatmyswan" date="1230186986"]I am doing a simple user registration. I
Now I am ready to insert the info into the database. something like this.
Code:
$data = array(
                'email' => 'email???',
                'password' => 'password???',
                'first_name' => 'first_name???',
                'registration_date' => now(),
                'last_name' => 'last_name????',
                'phone' => 'phone????',
        
            );
            $this->db->insert('tblcustomers', $data);
I need to insert the prepped data instead of just the POST data. How do I go about doing this???

Any helo will be greatly appreciated. Thanks![/quote]

Code:
$data = array(
                'email' => $this->input->post('email'),
                'password' => $this->input->post('password'),
                'first_name' => $this->input->post('first_name'),
        'registration_date' => now(),
                'last_name' => $this->input->post('last_name'),
                'phone' => $this->input->post('phone'),
        
            );
            $this->db->insert('tblcustomers', $data);

Merry christmas
#4

[eluser]Unknown[/eluser]
Thank You Both. Merry Christmas!




Theme © iAndrew 2016 - Forum software by © MyBB