按照MVC样式在PHP中保存数据库中的IP地址

I am implementing a functionality in application where user can transfer money from one person's account to anothers. Once they click on Transfer button after all the account details, I want to get the IP address of the user and to save it in a DB. I am following MVC style and Php to develop this application. I am confused with the flow, I should follow. I have three files: 'view.php' that give the form to enter the details, the controller and the model.

After searching on internet, i found the following way to get the IP address. but I don't know how to send it to database.

  $IP = $_SERVER['REMOTE_ADDR'];

Also I find another way using jQuery to get IP address,

  $(#transfer).on("click",function(){
      $.getJSON("http://jsonip.com/?callback=?", function (ipaddr) {
         console.log(ipaddr);
         // alert(ipaddr.ip);
      });
  });

How to send the IP address to my database using any of the above. Need help. Thanks in advance.

Why you don't use a insert/update query to save IP address in database?

Just insert it as a simple string using AJAX or just simple PHP. Do you have any experience with sql and executing sql from php? E.g.

INSERT INTO logs (`ip,`date`) VALUES         ($ip, $date); (mysql)

Note that the query might vary depending on your sql server and your table/needs.