GeniousRus
asked on
Get ip location
i got java script which can fetch the ip location
<script language="Javascript" src="http://gd.geobytes.com/gd?after=-1&variables=GeobytesCountry,GeobytesCity"></script><script language="Javascript">docu ment.write (" "+sGeobytesCity+", "+sGeobytesCountry);</scri pt>';
so i want to pass those variables into an email ,, wt i did is :
<?php
function get_loc()
{
$get = '<script language="Javascript" src="http://gd.geobytes.com/gd?after=-1&variables=GeobytesCountry,GeobytesCity"></script><script language="Javascript">docu ment.write (" "+sGeobytesCity+", "+sGeobytesCountry);</scri pt>';
return $get;
}
$message = "user info:". get_loc();
// Send E-mail
mail('email', 'subject', $message);
?>
so when someone opens that page it will send an email but it didnt work, the mail shows this
user info:<script language="Javascript"
src="http://gd.geobytes.com/gd?after=-1&variables=GeobytesCountry,GeobytesCity"></script><script
language="Javascript">docu ment.write (" "+sGeobytesCity+",
"+sGeobytesCountry);</scri pt>
==========
any help would be much appreciated...
<script language="Javascript" src="http://gd.geobytes.com/gd?after=-1&variables=GeobytesCountry,GeobytesCity"></script><script language="Javascript">docu
so i want to pass those variables into an email ,, wt i did is :
<?php
function get_loc()
{
$get = '<script language="Javascript" src="http://gd.geobytes.com/gd?after=-1&variables=GeobytesCountry,GeobytesCity"></script><script language="Javascript">docu
return $get;
}
$message = "user info:". get_loc();
// Send E-mail
mail('email', 'subject', $message);
?>
so when someone opens that page it will send an email but it didnt work, the mail shows this
user info:<script language="Javascript"
src="http://gd.geobytes.com/gd?after=-1&variables=GeobytesCountry,GeobytesCity"></script><script
language="Javascript">docu
"+sGeobytesCountry);</scri
==========
any help would be much appreciated...
Now i realized that i forget a couple of things. Try this code.
<?php
function get_loc()
{
if (($handle = file('http://gd.geobytes.com/gd?after=-1&variables=GeobytesCountry,GeobytesCity')))
{
return $handle;
}
else
{
return 'Could not get geobytes location';
}
}
$ar = get_loc();
$array = explode(';', $ar[0]);
$message = "user info:". chr(32) . $array[1] . chr(32) . $array[2];
mail('email', 'subject', $message);
?>
<?php
function get_loc()
{
if (($handle = file('http://gd.geobytes.com/gd?after=-1&variables=GeobytesCountry,GeobytesCity')))
{
return $handle;
}
else
{
return 'Could not get geobytes location';
}
}
$ar = get_loc();
$array = explode(';', $ar[0]);
$message = "user info:". chr(32) . $array[1] . chr(32) . $array[2];
mail('email', 'subject', $message);
?>
ASKER
i guess it works now ..but not in proper way..
user info: var sGeobytesCountry="Malaysia
so how do i just show "Malaysia Petaling Jaya"
var sGeobytesCountry="Malaysia "
var sGeobytesCity="Petaling Jaya"
var something = sGeobytesCountry + " " + sGeobytesCity
That should work.
var sGeobytesCity="Petaling Jaya"
var something = sGeobytesCountry + " " + sGeobytesCity
That should work.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try this in PHP
<?php
function get_loc()
{
if (($handle = 'http://gd.geobytes.com/gd?after=-1&variables=GeobytesCountry,GeobytesCity'))
{
return $handle;
}
else
{
return false;
}
}
$message = "user info:". get_loc();
mail('email', 'subject', $message);
?>