-6

So, I wanted to write myself a Java program, which will send a bunch of data (probably formatted as JSON) to my website, which will then write that data to MySQL, but I also want my website to get the IP, from which this data was sent.

But is this even possible? I don't have too much experience with PHP :/

Kamilkime
  • 238
  • 3
  • 7

1 Answers1

1

The answer is here: http://stackoverflow.com/questions/15699101/get-the-client-ip-address-using-php

Easy solution is:

$IP = $_SERVER['REMOTE_ADDR'];
spelgubbe
  • 56
  • 4
  • I thought, that way I can get an IP of a client, who is actually looking at my website, not the IP adress, from which some data (in my case - a file) was sent – Kamilkime May 29 '16 at 12:08
  • You need to access your website to send data to it. In the same script which you send the data to, you could use this code to get the IP if the client who is sending the data. You'd want to either include the data from your java program in a request to your website, and then fetch it from PHP using either the $_POST['key'] or $_GET['key'] server-side variables. – spelgubbe May 29 '16 at 16:34