按下按钮时的Codeigniter更新表

I am trying to use Codeigniter to create an application where when a button is pressed that it'll add 1 to an INT column in a table.

There is 3 buttons and depending on which button is pressed it'll update one of the 3 columns adding the value.

I've got so when a user logs in that the username and password they log in with is set into the table with the inputs.

Table:

+--+--------+--------+--------+--------+----------+
|ID|Password|Username|inputOne|inputTwo|inputThree|
+--+--------+--------+--------+--------+----------+
|  |        |        |        |        |          |
|  |        |        |        |        |          |
+-------------------------------------------------+

After the user is logged in this should be recorded

+--+--------+--------+--------+--------+----------+
|ID|Password|Username|inputOne|inputTwo|inputThree|
+--+--------+--------+--------+--------+----------+
|1 |Pass    |User1   |        |        |          |
|  |        |        |        |        |          |
+-------------------------------------------------+

I only need it to update the column depending on which button is being pressed. The other columns should not add. Until that button is pressed.

I am also trying to do it so that the page doesn't redirect when the button is pressed.

The Process:

View

    <script src="<?php echo site_url('application/views/js/buttons.js')?>"></script>
    <form method="post">
     <input class="btn btn-lg btn-success" type="submit" id="inputOne" value="Button One"><br><br>
     <input class="btn btn-lg btn-primary" type="submit" id="inputTwo" value="Button Two"><br><br>
     <input class="btn btn-lg btn-danger" type="submit" id="inputThree" value="Button One">
   </form>

buttons.js

$(document).ready(function(){

$("#inputOne").click(function()
{
 $.ajax({
     type: "POST",
     url: "<?php echo base_url(); ?>index.php/home/view",
     data: {"1"},
     success:
          function(){
            sleep(5);  //STOP POST
          }
      });
 return false;
});

$("#inputTwo").click(function()
{
 $.ajax({
    type: "POST",
    url: "<?php echo base_url(); ?>index.php/home/view",
    data: {"1"},
    success:
         function(){
           sleep(5);  //STOP POST
         }
     });
 return false;
});

$("#inputThree").click(function()
{
 $.ajax({
   type: "POST",
   url: "<?php echo base_url(); ?>index.php/home/view",
   data: {"1"},
   success:
        function(){
          sleep(5);  //STOP POST
        }
    });
 return false;
});


});

Controller

public function buttons() {
 if (!$this->session->userdata('username')){
  redirect (base_URL(). 'index.php/login/view');
 } else {
  if (!$this->session->userdata('password')) {
   redirect (base_URL(). 'index.php/login/view');
  } else {
   if (date('H:i:s') > $this->session->userdata('endTime')) {
     redirect (base_URL(). 'index.php/login/view');
   } else {
     $this->model->load('buttons_model');
   }
  }
 }
}

Model

<?php

class buttons_model extends CI_Model {


      public function __construct()
  {
          parent::__construct();
  }


public function alterinput() {

    $Username = $this->session->userdata('username');
$Password = $this->session->userdata('password');

$sql = "UPDATE input 
 SET inputOne = (inputOne + 1),
  inputTwo = (inputTwo + 1),
  inputThree = (inputThree + 1)
 WHERE (classPassword = '" . $Username . "',
  Username = '" . $Password . "') ";

      $this->db->query($sql);

  //---------------------------------------
  // END OF FILE
  //---------------------------------------
}

Where am I going wrong in trying to get the columns to update depending on the button press?

The error I'm getting is that I cannot get the values to enter separately, when Button One is pressed Only inputOne should add and the rest shouldn't

As an example, if I pressed Button One whilst I'm logged in as User1 the table should now look like:

+--+--------+--------+--------+--------+----------+
|ID|Password|Username|inputOne|inputTwo|inputThree|
+--+--------+--------+--------+--------+----------+
|1 |Pass    |User1   |1       |        |          |
|  |        |        |        |        |          |
+-------------------------------------------------+

You will need one click event for all buttons that runs an AJAX request to a controller that does your process, once the controller finishes and you want to update the DB, call teh model and the method for updating by + 1.

JS

$(".btn-lg").on('click', function(e){
    e.preventDefault(); // this will prevent the defualt behavior of the button

    // find which button was clicked
    butId = $(this).attr('id');

    $.ajax({
          method: "POST",
          url: "/controllerDummy/run/",
          data: { button: butId }
        })
      .done(function( msg ) {
        // do something
      });        
});

Controller

// first get the button that was pressed
button = $_POST['button']; // will be the id of the button that was clicked

// do your code here.....

// once completed load the model and run the method of updating...
$this->load->model('button_model');
$this->button_model->methodName();

// if you need it only for specific buttons use an if statement