Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   hwo to redirect users depending on their country in php (with maxmind geoip) ? (http://www.go4expert.com/forums/hwo-redirect-users-depending-country-t20364/)

iglow 14Dec2009 15:40

hwo to redirect users depending on their country in php (with maxmind geoip) ?
 
Exactly as mentioned i have trouble wit hthat. I want to use the maxmind geoip base in php so that when user comes to my aaa.com then it checks if hes from .be .fr .ca and puts him on aaa.com/1.htm, if from .uk .au .us to aaa.com/2.htm anf if from other place tio aaa.com/3.htm [or .php doesnt matter here]
Im sure its simple but somehow i cant code it. Would love the help of some expert ;)

venami 14Dec2009 17:15

Re: hwo to redirect users depending on their country in php (with maxmind geoip) ?
 
You can use the Geo IP Location extension of PHP.

Please see the link below:

http://php.net/manual/en/book.geoip.php

iglow 14Dec2009 18:19

Re: hwo to redirect users depending on their country in php (with maxmind geoip) ?
 
im reading that but looks complex to me, im not so good with php [i can edit simple parts but mainly i need more 'step by step' info.
cant i just upload the files of geoip and put 2-3 pages of php code that will read them and make use of them? this looks a bit too complex with those shell commands

thanx

venami 14Dec2009 18:32

Re: hwo to redirect users depending on their country in php (with maxmind geoip) ?
 
I have never heard of Geo IP extension of PHP earlier. I came to know about it only after your question. I also have to go through it to know more about GeoIP. :)

iglow 14Dec2009 18:42

Re: hwo to redirect users depending on their country in php (with maxmind geoip) ?
 
im sure it can be done in php just by uploading all the files [not even importing to mysql] and using 1-2 .php files - ive seen such thing, but i have no idea how to do it and my knowledge of php doesnt allow me it seems ;)

happy i

shabbir 14Dec2009 19:33

Re: hwo to redirect users depending on their country in php (with maxmind geoip) ?
 
Quote:

Originally Posted by venami (Post 61671)
I have never heard of Geo IP extension of PHP earlier. I came to know about it only after your question. I also have to go through it to know more about GeoIP. :)

Search the Articles and you would see it here as well.

iglow 14Dec2009 19:37

Re: hwo to redirect users depending on their country in php (with maxmind geoip) ?
 
Quote:

Originally Posted by shabbir (Post 61676)
Search the Articles and you would see it here as well.

shabbir ive searched and i found some similar stuff but not exactly o nthe topic. i found only blocking by country in .htaccess with using php. and thats totally not what i want to do :)

@ venami and i couldnt edit the post abouve but i wanted to say im happy i shown u something new with my question :)

shabbir 15Dec2009 09:41

Re: hwo to redirect users depending on their country in php (with maxmind geoip) ?
 
Did you see Getting Visitor's Country with PHP using Geo IP

iglow 15Dec2009 13:07

Re: hwo to redirect users depending on their country in php (with maxmind geoip) ?
 
Quote:

Originally Posted by shabbir (Post 61705)

hey yes ive seen but the modification seems not that obvious,
have a look:

Code:


<?php

// include functions
include("geoip.inc");

// read GeoIP database
$handle = geoip_open("GeoIP.dat", GEOIP_STANDARD);

// map IP to country
echo "IP address 62.149.130.132 located in " . geoip_country_name_by_addr($handle, "62.149.130.132") . " (country code " . geoip_country_code_by_addr($handle, "62.149.130.132") . ")";

// close database handler
geoip_close($handle);

// print compulsory license notice
echo "<p> -- This product includes GeoIP data created by MaxMind, available from http://maxmind.com/ --";

?>



this code is suspossed to read the country code by using function include(). but now im not sure how to make working variabilities to redirect people from 9 countries [3 groups each for 3 countries] to 3 different adresses also not sure what kind iof redirect should be used.
if somebody could have a look at this i would be pleased :)

shabbir 15Dec2009 20:02

Re: hwo to redirect users depending on their country in php (with maxmind geoip) ?
 
Redirect should be plan header if possible or else could be anything you like but the 3 countries of 3 group looks very simple. Whats the issue there.


All times are GMT +5.5. The time now is 18:22.