Best Blackhat Forum

Full Version: [NEED HELP!] Codeigniter Code Validation!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello BBHF's Members

I'm sorry if im wrong to post this thread in this section.

i need help to validate that the email with no duplication and the name, middlename lastname also, when i add a full info of a student.
Example:
Magic Button :
when a add a student name
"Brendon Rayle G. Montoya"
it will add for a new record, if still the same name in the example it will prompt
"Student name is Already Exist"
if i add a new student still the same Name and Lastname but the Middle name is not
it will be valid to add. same process in updating student.

Here's the Controller Code
Code:
function student($param1 = '', $param2 = '', $param3 = '')
{
    if ($this->session->userdata('admin_login') != 1)
        redirect('login', 'refresh');
    if ($param1 == 'create') {
        $data['name']        = $this->input->post('name');
        $data['mname']       = $this->input->post('mname');
        $data['lastname']    = $this->input->post('lastname');
        $data['birthday']    = $this->input->post('birthday');
        $data['sex']         = $this->input->post('sex');
        $data['address']     = $this->input->post('address');
        $data['phone']       = $this->input->post('phone');
        $data['email']       = $this->input->post('email');
        $data['password']    = md5($this->input->post('password'));
        $data['father_name'] = $this->input->post('father_name');
        $data['mother_name'] = $this->input->post('mother_name');
        $data['class_id']    = $this->input->post('class_id');
        $data['roll']        = $this->input->post('roll');
        $this->db->insert('student', $data);
        $student_id = mysql_insert_id();
        move_uploaded_file($_FILES['userfile']['tmp_name'], 'uploads/student_image/' . $student_id . '.jpg');
        $this->email_model->account_opening_email('student', $data['email']); //SEND EMAIL ACCOUNT OPENING EMAIL
        $this->session->set_flashdata('flash_message', get_phrase('add_student_success'));
        redirect(base_url() . 'index.php?admin/student/' . $data['class_id'], 'refresh');
    }
    if ($param2 == 'do_update') {
        $data['name']        = $this->input->post('name');
        $data['mname']       = $this->input->post('mname');
        $data['lastname']    = $this->input->post('lastname');
        $data['birthday']    = $this->input->post('birthday');
        $data['sex']         = $this->input->post('sex');
        $data['address']     = $this->input->post('address');
        $data['phone']       = $this->input->post('phone');
        $data['email']       = $this->input->post('email');
        $data['password']    = md5($this->input->post('password'));
        $data['father_name'] = $this->input->post('father_name');
        $data['mother_name'] = $this->input->post('mother_name');
        $data['class_id']    = $this->input->post('class_id');
        $data['roll']        = $this->input->post('roll');

        $this->db->where('student_id', $param3);
        $this->db->update('student', $data);
        move_uploaded_file($_FILES['userfile']['tmp_name'], 'uploads/student_image/' . $param3 . '.jpg');
        $this->crud_model->clear_cache();
        $this->session->set_flashdata('flash_message', get_phrase('edit_student_success'));
        redirect(base_url() . 'index.php?admin/student/' . $param1, 'refresh');
    } else if ($param2 == 'edit') {
        $page_data['edit_data'] = $this->db->get_where('student', array(
            'student_id' => $param3
        ))->result_array();
    } else if ($param2 == 'personal_profile') {
        $page_data['personal_profile']   = true;
        $page_data['current_student_id'] = $param3;
    } else if ($param2 == 'academic_result') {
        $page_data['academic_result']    = true;
        $page_data['current_student_id'] = $param3;
    }
i'm so newbie in making validation in this program please help me doing this.
and i will pay who helped me.
when its done i will give a $50 and name what script, themes you want.,
I will be able to help you with this. Not at my computer at the moment
(09-14-2014 05:35 PM)lolclol Wrote: [ -> ]I will be able to help you with this. Not at my computer at the moment
it would be great. that you can help me..
(09-14-2014 05:37 PM)HaselBiscuit Wrote: [ -> ]
(09-14-2014 05:35 PM)lolclol Wrote: [ -> ]I will be able to help you with this. Not at my computer at the moment
it would be great. that you can help me..
U realize this is the wrong section right :P But u post cool stuff so ill forgive ;) have u checked the validation scripts inside codeigniter apps, like pintastic for example ?
https://ellislab.com/codeigniter/user-gu...ation.html

http://stackoverflow.com/questions/82202...tion-rules



http://www.formget.com/form-validation-u...deigniter/


https://www.packtpub.com/books/content/f...igniter-17


maybe that helps.

If u want to learn the best way is to take apart something that exists, soon as u understand it, break it on purpose, and try to fix it :P

If u want to pay someone $50 to write it for u, hell yes ill do and wrap a ribbon around it too..but honestly u would be better off gaining the XP yourself.
Need to update my phpStorm, and ill see if i cant do it for u for free.. in all honesty i need all the practice i can get too. im busy rewriting all the pintastic apps from ground up using fresh codeigniter base. for me the best way to understand it has been actually writing and debugging... reading gives me headaches and i get bored.
Reference URL's