Enquiry Page with IP and Location Tracker Using PHP

By | January 2, 2014

Enquiry page in a website is indeed, enquiry page is the very shortest way for visitor to communicate with the website team. Tracking the location and IP address of the visitor, who send enquiry may help website team, where is the visitor is from?. Here is the tutorial for how to track visitor from enquiry page using php.


Enquiry Page with IP and Location Tracker Using PHP jQuery

Enquiry Page with IP and Location Tracker Using PHP jQuery


NOTE: Any type of validation is not included in this script

PHP Code

[code type=php]


$_ip = new ip_codehelper();
$real_client_ip_address = $_ip->getRealIP();
$visitor_location = $_ip->getLocation($real_client_ip_address);

$guest_ip = $visitor_location[‘IP’];
$guest_country = $visitor_location[‘CountryName’];
$guest_city = $visitor_location[‘CityName’];
$guest_state = $visitor_location[‘RegionName’];


$subject = “Enquiry Mail”;
$headers .= “MIME-Version: 1.0\r\n”;
$headers .= “Content-Type: text/html; charset=ISO-8859-1\r\n”;

$message = ‘<html><body>’;
$message.='<h1>Enquiry Mail</h1>’;
$message.='<div style=”border: 10px solid #0095DE; padding: 10px;”><br/>’;
$message.=’__________________________________________________<br/><br/><h2><b>Visitor Details</h2>’;
$message.='<div style=”margin:10px 0;”><b>IP Address</b>&nbsp;&nbsp;&nbsp;&nbsp;’.$guest_ip.'</div>’;
$message.='<div style=”margin:10px 0;”><b>Country</b>&nbsp;&nbsp;&nbsp;&nbsp;’.$guest_country.'</div>’;
$message.='<div style=”margin:10px 0;”><b>State</b>&nbsp;&nbsp;&nbsp;&nbsp;’.$guest_state.'</div>’;
$message.='<div style=”margin:10px 0;”><b>City</b>&nbsp;&nbsp;&nbsp;&nbsp;’.$guest_city.'</div></div>’;

echo “<script type=’text/javascript’>alert(‘Thank you, we have received your enquiry.’);</script>”;
<form method=”post” action=””>

<input type=”text” name=”name” id=”name3″ />

<input type=”text” name=”email” id=”email” />


<input type=”submit” name=”submit” id=”submit”/>


4 thoughts on “Enquiry Page with IP and Location Tracker Using PHP

  1. Akila

    Hi. . Location tracking is not working for me. Failed to connect mail server. Plz reply


Leave a Reply

Your email address will not be published. Required fields are marked *