dpr26232 2018-02-05 19:30
浏览 50

按照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.

  • 写回答

2条回答 默认 最新

  • dsgdf45654 2018-02-05 19:45
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥50 三种调度算法报错 采用的你的方案
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥15 对于这个问题的解释说明
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败