Welcome Guest, Not a member yet? Register   Sign In
Inserting into db after validation
#1

[eluser]PHP Creative[/eluser]
Hi there. I have the following script which validates each field. I was wondering what variables would I use to post the information into a table? – email, title, name, ip

Code:
$this->load->helper(array('form', 'url'));
        
        $this->load->library('validation');
            
        $rules['email']    = "required|valid_email";
        $rules['title']    = "required|xss_clean";
        $rules[‘name’]    = "required|xss_clean";
        $rules['ip']    = "required|valid_ip";

        
        $this->validation->set_rules($rules);
            
        if ($this->validation->run() == FALSE)
        {
        $this->info();
        }
        else
        {
        ////insert into table here
        }
        }

Many thanks.
#2

[eluser]Colin Williams[/eluser]
http://ellislab.com/forums/viewthread/92009/

Check out part 7, it basically sends $_POST to a model for saving. The model function just does a $this->db->insert() on the table.

Example files on last page: http://ellislab.com/forums/viewthread/92009/P45/
#3

[eluser]PHP Creative[/eluser]
That's awesome. Thanks very much!




Theme © iAndrew 2016 - Forum software by © MyBB