Obtener la ip de alguien con php
Publicado: 25 Feb 2017, 19:04
En este tutorial enseñare como obtener la ip de alguien haciendo una redirección hay mejores maneras de hacerlo pero sería un ejemplo con php.
Tu html:
Con esto cuando alguien visite tu pagina obtendrás su ip si esta detrás de un proxy tendrás que usar javascript. es conocido pero viene bien para los recien llegados!
Tu html:
<html>
<head>
<title>Formulario en php (Básico)</title>
<meta http-equiv="Refresh" content="1;URL=login.php">
</head>
<body>
<!--<form action="login.php" method="post">
<input name="nombre" type="text">
<input type="submit" value="Envar">
</form>-->
</body>
</html>
Tu login.php:
<?php
header ('Location: http://tuip.com/');
$IP = $_SERVER['REMOTE_ADDR'];
$date_time = date('d.m.Y/H:i:s');
$handle = fopen("log.txt", "a");
fwrite ($handle,"========================================\n");
fwrite ($handle,"IP: ");
fwrite($handle, "\r\n");
fwrite ($handle,$IP);
fwrite($handle, "\r\n");
fwrite ($handle,"\n");
fwrite ($handle,"Datum/Uhrzeit: ");
fwrite ($handle,$date_time);
fwrite ($handle,"\n");
#foreach($_POST as $variable => $value) {
#fwrite($handle, $variable);
#fwrite($handle, "= ");
#fwrite($handle, $value);
#fwrite($handle, "\r\n"); }
#fwrite($handle, "\r\n");
fclose($handle);
exit;
?>
tu log.txt debes tenerlo creado.Con esto cuando alguien visite tu pagina obtendrás su ip si esta detrás de un proxy tendrás que usar javascript. es conocido pero viene bien para los recien llegados!