Skip to content

Instantly share code, notes, and snippets.

@michaelnagy
Last active January 28, 2023 19:04
Show Gist options
  • Save michaelnagy/5482206 to your computer and use it in GitHub Desktop.
Save michaelnagy/5482206 to your computer and use it in GitHub Desktop.
Simple PHP script to get the user IP and writes it to the file.
<?php
//get tht ip from the user
$ip=$_SERVER['REMOTE_ADDR'];
//open or create the file
$arquivo = fopen($filename, "a");
if ($arquivo == false) {
die('Error message creating or opening the file.');}
//write to the file the IP from the user
if (!fwrite($arquivo, $ip."\n")) die('Error updating the file.');{
echo 'Sucess.';
fclose($arquivo);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment