<?php

class Memebership_model extends CI_Model{

    function validate(){

        $this->db->where('username',$this->imput->post('username'));

        $this->db->where('password',md5($this->imput->post('password')));
        $query=$this->db->get('user');

        if($query->num_rows == 1){


            return true;
        }
    }

function create_member(){
    $username=$this->input->post('username');

    $new_member_insert_data=array(

        'first_name'=>$this->input->post('first_name'),
        'last_name'=>$this->input->post('last_name'),
        'email'=>$this->input->post('email'),
        'username'=>$this->input->post('username'),
        'username'=>md5($this->imput->post('password'))
    );

    $insert=$this->db->insert('users',$new_member_insert_data);
    return $insert;
}

    function  check_if_username_exists($username){

        $this->db->where('username',$username);
        $result=$this->db->get('users');

        if($result->num_rows()>0){

            return FALSE;

        }
        else{

            return TRUE;

        }
    }

    

}

?>