Welcome Guest, Not a member yet? Register   Sign In
Please help me with this issue
#1

[eluser]aryan_[/eluser]
Here's my signup code

Code:
function signup(){
        $this->load->library('form_validation');
        $data['page'] = 'account/signup';
        $data['nav'] = 0;
        $data['error_msg'] = '';
        
        //set form validation
        $this->form_validation->set_rules('fname','First Name', 'required|xss|trim');
        $this->form_validation->set_rules('lname','Last Name', 'xss|trim');
        $this->form_validation->set_rules('email','Email', 'required|xss|trimcallback_validate_email|valid_email|');
        $this->form_validation->set_rules('rdisease','Rare Disease', 'required|xss|trim');        
        $this->form_validation->set_rules('state','State', 'required|xss|trim');
        $this->form_validation->set_rules('country','Country', 'required|xss|trim');
        $this->form_validation->set_rules('zip','Zip', 'required|xss|trim');
        $this->form_validation->set_rules('age','Age', 'required|xss|trim|numeric');
        $this->form_validation->set_rules('uname','User Name', 'required|xss|trim|callback_validate_un|alpha_dash');
        $this->form_validation->set_rules('passw','Password', 'required|xss|trim|min_length[6]');
        $this->form_validation->set_rules('opttc','Terms & Condition', 'required');
        if($this->uri->segment(3) != 0){
            $this->form_validation->set_rules('ukey','Key', 'required|trim|xss|validate_key');
        }
        
        $this->form_validation->set_error_delimiters('<li>', '</li>');
        
        if($this->form_validation->run() == TRUE){
            $val = array();
            
            //get(if user exists) or generate unique key
            if($this->uri->segment(3) != 0){
                $uid = $this->input->post('ukey');
            }
            else{
                $uid = uniqid();
                $val['key'] = $uid;
            }
            
            
            //collect all table fields value
            $val['fname'] = $this->input->post('fname');
            $val['lname'] = $this->input->post('lname');
            $val['email'] = $this->input->post('email');
            $val['diseasetype'] = $this->input->post('rdisease');
            $val['city'] = $this->input->post('city');
            $val['state'] = $this->input->post('state');
            $val['country'] = $this->input->post('country');
            $val['zip'] = $this->input->post('zip');
            $val['age'] = $this->input->post('age');
            $val['username'] = $this->input->post('uname');
            $val['password'] = md5($this->input->post('passw'));
            $val['optkelf'] = $this->input->post('optkelf');
            $val['optkelfp'] = $this->input->post('optkelfp');
            $val['datesignup'] = time();
            
            //upload artists image
            if($_FILES['ufile']['name'][0] != ''){
                $config['upload_path'] =  realpath('uploads/' . $uid);
                $config['allowed_types'] = 'jpg|png|gif';
                $config['max_size'] = '2048';
                $this->load->library('upload', $config);
                
                if(!$this->upload->do_upload('ufile')){
                echo('error');
                    $data['error_msg'] = $this->upload->display_errors('<li>', '</li>');
                }
                $filedata = $this->upload->data();
                $val['image'] = $filedata['file_name'];
            }
            
            //insert or update db
            if($this->uri->segment(3) != 0){
                $this->db->where('key', $uid);
                $this->db->update('artists', $val);
            }
            else{
                $this->db->insert('artists', $val);
            }
            
        }
        
        
        $this->load->view('tpl', $data);
    }

I have defined callback functions "validate_email", "validate_key" and "validate_un" in the same controller.

When I submit form data is inserted/updated event if there is an error. Am I missing something?


Messages In This Thread
Please help me with this issue - by El Forum - 05-24-2010, 04:04 AM
Please help me with this issue - by El Forum - 05-24-2010, 04:11 AM
Please help me with this issue - by El Forum - 05-24-2010, 04:27 AM
Please help me with this issue - by El Forum - 05-24-2010, 04:34 AM
Please help me with this issue - by El Forum - 05-24-2010, 04:53 AM
Please help me with this issue - by El Forum - 05-24-2010, 05:36 AM
Please help me with this issue - by El Forum - 05-24-2010, 02:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB