PDA

View Full Version : Inserting user IP address into MySQL DB



phpchick
02-24-2012, 07:27 AM
var ip = '<!--#echo var="REMOTE_ADDR"-->';
xmlhttp.open("GET","getuser.php?q="+str+"&ip="+ip,true);
xmlhttp.send();


I'm sending the above via a GET to a php file that inserts into a DB.

here is the php portion


<?php
$q=$_GET["q"];
$ip=$_GET["ip"];

$sql="INSERT INTO statcounter (selection, ip) VALUES ('".$q."','".$ip."')";


It is inserting properly into the DB, but the IP isn't correct. In the IP field I'm getting "<!--" instead of the users IP address. Would anyone have any advice on this?


I took the first line from this website
http://javascriptsource.com/user-details/ip-address.html
Apparently they were able to get the IP from only using

var ip = '<!--#echo var="REMOTE_ADDR"-->';

But I'm not sure how they were able to do this

abduraooft
02-24-2012, 11:26 AM
var ip = '<!--#echo var="REMOTE_ADDR"-->'; What's that language?