Tuesday, 21 June 2016

IP address grabber in PHP

Simplest IP address grabber using PHP on Localhost:

1.Install LAMP/WAMP
2.Create the Database IP.


<?php
// gets the IP 
$IP = $_SERVER['REMOTE_ADDR'];

$con=mysqli_connect("localhost","root","","IP");

if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
//inserts the IP into the Database Table
mysqli_query($con,"INSERT INTO IP (ip)
VALUES ('$IP')");
 

mysqli_close($con);
?>

*****************************************************************
Database on MYSQL is IP
Must try on a live server rather than localhost.

****************************************************************

No comments:

Post a Comment