This is the modal of sign-in
<!-- Signin Small Modal-->
    <div class="modal fade bd-example-modal-sm" id="mySignModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <!--<div class="modal fade bd-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">-->
      <div class="modal-dialog modal-sm" role="document">
        <div class="modal-content">
           <div class="modal-header btn-primary">
            <h5 class="modal-title">Sign-in</h5>
            <!--<button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">×</span>
            </button>-->
          </div>
          <div class="modal-body">
            <form id="signinForm" action="" method="post">
              <input type="hidden" name="txtId" value="0">
              <div class="form-group">
                <label for="txtUsername" style="font-size: 12px;">Username</label>
                <input type="text" class="form-control" name="txtUsername" placeholder="Enter username">
                <!--<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>-->
              </div>
              <div class="form-group">
                <label for="txtEmail" style="font-size: 12px;">Email</label>
                <input type="email" class="form-control" name="txtEmail" aria-describedby="emailHelp" placeholder="Enter email">
                <!--<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>-->
              </div>
              <div class="form-group">
                <label for="txtPassword" style="font-size: 12px;">Password</label>
                <input type="password" class="form-control" name="txtPassword" placeholder="Password">
              </div>
              <div class="form-group">
                <label for="txtConfirmPass" style="font-size: 12px;">Confirm Password</label>
                <input type="password" class="form-control" name="txtConfirmPass" placeholder="Password">
              </div>
            </form>
          </div>
          <div class="modal-footer">
            <button type="button" id="btnRegister" class="btn-sm btn-success">Submit</button>
            <button type="button" class="btn-sm btn-secondary" data-dismiss="modal">Close</button>
          </div>
        </div>
      </div>
    </div>
under this is my javascript to insert the input from modals to my database
<script>
        $(function(){
            $('#btnCreateAccount').click(function(){
                $('#mySignModal').modal('show');
            });
            $('#btnRegister').click(function(){
                $('#mySignModal').find('.modal-title').text('Sign-in');
                $('#signinForm').attr('action', '<?php echo base_url() ?>index.php/login/addUsers');
            });
        });
    </script>
this is my login controller
public function addUsers(){
        $result = $this->em->addUsers();
        $msg['success'] = false;
        $msg['type'] = 'add';
        if($result){
            $msg['success'] = true;
        }
        echo json_encode($msg);
    }
and this is my Users model
public function addUsers(){
        $field = array(
            'username'=>$this->input->post('txtUsername'),
            'email'=>$this->input->post('txtEmail'),
            'password'=>$this->input->post('txtPassword')
            //'created_at'=>date('Y-m-d H:i:s')
            );
        /*$field = array(
            'username'=>'hardcoded username',
            'email'=>'hardcoded email',
            'password'=>'hardcoded email'
            //'created_at'=>date('Y-m-d H:i:s')
            );*/
        $this->db->insert('users', $field);
        if($this->db->affected_rows() > 0){
            return true;
        }else{
            return false;
        }
    }
It wont let me insert the data from sign-in modal to my database it wont let me when I check the url http://localhost/ci_testblog/index.php/login/addUsers it says that:
A Database Error Occurred
Error Number: 1048
Column 'username' cannot be null
INSERT INTO
users(username,password) VALUES (NULL, NULL, NULL)Filename: C:/xampp/htdocs/ci_testblog/system/database/DB_driver.php
Line Number: 691
What could be wrong on this one?
 
     
     
    