-1

So i have a website which people can access buy useing a password.

Example:
http://www.MyWebsite.com/?pass=YourPassword

I was wondering how to log the ip's in a .txt file with the ?pass that they used. So that i can see what ip's are used on what password. Any help would be appreciated! Thanks in advance.

1 Answers1

1

At the first: passing passwords through url is very bad idea. But let's assume that you are passing some other data through $_GET['pass'].

Here is described how to get user's IP address: https://stackoverflow.com/a/3003233/3845412

Your script should do something like that:

$ip = your_function_that_gets_user_ip();
$pass = $_GET['pass'];

file_put contents('file.txt', implode(',', [$pass, $ip]) . PHP_EOL, FILE_APPEND);

which makes file.txt using format like:

127.0.0.1,secret    
192.168.137.1,foopassword
Community
  • 1
  • 1
piotr
  • 1,282
  • 1
  • 8
  • 20