HTML and Java Q, Different content for different countries??

elecsho

Power Member
Joined
Apr 21, 2012
Messages
554
Reaction score
159
Just a quick question. I am trying to use html codes under the <head> tag that would be different according to each country. I will be using this java script plugin take a look:
Code:
http://www.geoplugin.com/examples
.

If you know how please show an example here. So what I am trying to do for example is: If a visitor is from the US show html code #1. Otherwise show html code #2.

Help is very appreciated!
 
You can just use the sample code provided in the url you gave. I have replaced some stuff so it looks like this. I've not tested it but I think this should work.


PHP:
<?php 

$geoPlugin_array = unserialize( file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $_SERVER['REMOTE_ADDR']) ); 

if ( $geoPlugin_array['geoplugin_countryName'] == 'US' ) 
{  // do your stuff for US}

else{    // do stuff for other country's} 

?>
 
Last edited:
You can just use the sample code provided in the url you gave. I have replaced some stuff so it looks like this. I've not tested it but I think this should work.


<?php$geoPlugin_array = unserialize( file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $_SERVER['REMOTE_ADDR']) ); if ( $geoPlugin_array['geoplugin_countryName'] == 'US' ) { //let's use a different base currency
// do your stuff for US}else{ // do stuff for other country's}?>
Thank you for this. But I suck at coding how can I use html code in the "Do your stuff for US here"
 
There are many ways to go. But you have to explain wat you want to do. Give a example of the US part you want to show and the Other Country part. And what is your source ? Are you getting the text from a database or is it all just plain html ?
 
There are many ways to go. But you have to explain wat you want to do. Give a example of the US part you want to show and the Other Country part. And what is your source ? Are you getting the text from a database or is it all just plain html ?

Okay this is exactly what I am trying to do. I am using content locker pro. I want to show different lockers according to the country. So if visitor is from the us, Use html code #1 which is for locker #1. Otherwise use html code #2 which for content locker #2.
 
If I'm not mistaken, content locker pro has that build in. I think you can set it in the admin panel.
I'm not sure because I don't have content locker pro. Maybe someone who owns content locker pro can tell you or maybe they have a support forum.

Otherwise maybe this would help (not the most elegant solution but it should work):


PHP:
<?php 
$geoPlugin_array = unserialize( file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $_SERVER['REMOTE_ADDR']) ); 
if ( $geoPlugin_array['geoplugin_countryName'] == 'US' ) {?>
//paste the code (html) from your content locker for US below this text and before <?}else{?>

<?}else{?>
//paste the code (html) from your content locker for Other Country's below this text and before <?}?>

<?}?>

Let me know if that's working
 
If I'm not mistaken, content locker pro has that build in. I think you can set it in the admin panel.
I'm not sure because I don't have content locker pro. Maybe someone who owns content locker pro can tell you or maybe they have a support forum.

Otherwise maybe this would help (not the most elegant solution but it should work):


PHP:
<?php 
$geoPlugin_array = unserialize( file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $_SERVER['REMOTE_ADDR']) ); 
if ( $geoPlugin_array['geoplugin_countryName'] == 'US' ) {?>
//paste the code (html) from your content locker for US below this text and before <?}else{?>

<?}else{?>
//paste the code (html) from your content locker for Other Country's below this text and before <?}?>

<?}?>

Let me know if that's working
I dont know if it is working. How can I use this code on a free blog. Lets say I host this script on my own domain and want to use it on blogger.
 
oh and I did not find this option in clp. Geo-targeting is only for the offers not for the whole lockers
 
Well I think, for safety reasons, you cannot use php code in blogger. I think what you want is not possible with php. Maybe with javascript. But than you have to write a custom script for this. I'm not very good at javascript, so I cannot really help you with that.

php code is a server based language which means that the code is processed on the server. After that it can output it's results to the user (browser)

However, you can use this code on any free hosting site that allows you to add your own files.
For example www.[B]000[/B]webhost.com

p.s. I have never used this hosting service
 
Well I think, for safety reasons, you cannot use php code in blogger. I think what you want is not possible with php. Maybe with javascript. But than you have to write a custom script for this. I'm not very good at javascript, so I cannot really help you with that.

php code is a server based language which means that the code is processed on the server. After that it can output it's results to the user (browser)

However, you can use this code on any free hosting site that allows you to add your own files.
For example www.000webhost.com

p.s. I have never used this hosting service

I know blogger was just an example. I mentioned that I will host the script on my own server or I will use weebly to upload the php file. But what is the html code to load this script when using something like weebly or 000webhost
 
I think it's kinda hard to do this. This is because of safety issues. You have to upload the files from content locker pro to each website you want to use it on. I'm sorry but that's the only thing I can think of. Maybe someone else has a other idea about this ?
 
I think it's kinda hard to do this. This is because of safety issues. You have to upload the files from content locker pro to each website you want to use it on. I'm sorry but that's the only thing I can think of. Maybe someone else has a other idea about this ?

No no you dont understand. All I am asking is how to use the script you gave me on a free hosting like weebly.
 
Well if you can use php on weebly than you could just paste the code between the body tags <body> </body> on a certain page.

By the way, do you know anything about html ?
Because if you don't this may be all to overwhelming and you better follow a basic html course online or if you don't have the time, pay someone to do this for you.
 
However, you can use this code on any free hosting site that allows you to add your own files.
How can I use the code by uploading it. Because I can't put php code directly in weebly.
 
Than you need to have access to the server via ftp. But I don't think you can do that on weebly.
Try 000webhost
After signing up you have access to ftp. In the control panel you can see your ftp credentials
 
Than you need to have access to the server via ftp. But I don't think you can do that on weebly.
Try 000webhost
After signing up you have access to ftp. In the control panel you can see your ftp credentials
okay but what will be the html code.
 
Well I cannot tell you that because I don't have content locker pro. So I don't know what content locker outputs, if you know what I mean
 
Back
Top