Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to grab and store executed value of a url

Status
Not open for further replies.

keith23

Technical User
May 26, 2005
97
NL
Hi all i got a url( that if i paste it in browser address bar it will return for me a value like this:
document.write('usa');

I want to grab only countryname value using php and store it in variable and later insert it in to mysql db. Could an expert show me how i can store the countryname into variable.Thanks
 
You will probably find the the value of [red]template=CountryName[/red] in the $_GET[] array.

try this:
Code:
[blue]$country=$_GET['[/blue][red]template[/red][blue]'];[/blue]

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
many thanks for u replies. vacunita how i can execute the url before i use your code? My intention is that when a user visits my php page it writes his country to mysql db so i want the url to be executed within my php and possibly i be print that value too. i be happy if show me how i can execute the url with in my php code.Thanks
 

I take it this URL is not part of your website. If that is the case, then you won't be able to acces their variables.

Maybe with sleipnir's suggestion you could get the value, but

I don't think that you will get your visitors country like that, because it will be your PHP code that is calling that URL and not your visitor.





----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
If I understand you rightly:

javascript on a page can be treated just like any other echo'd output.

so in your php script:

Code:
$countryName = "" ;//whatever and from wherever
echo "<script language=\"Javascript\" src=\"[URL unfurl="true"]http://map.geoup.com/geoup?template=$countryName\"[/URL] />";
 
Jpadie, open the website, so you know what its doing.

Keith23 wants to put the returned value i.e
Code:
document.write('[red]usa[/red]');
into a PHP variable, not send a variable to the website.

That's the catch, that website only returns a piece of text. nothing more. How you would interact with it to get the information is something you'd have to do by actually opening the URL. but again, it would be the script calling the URL, and not the visitor. which would defeat the purpose of actually running the script. keith32 wants the script to retunr the visitors country, not his own.



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
[sheepishly] @vacunita : i see the light...

two solutions:

1. include a wee iframe on your page. have the source of the iframe be the url above. on your main page insert a javascript pause for (say) 10 seconds then grab the contents of the iframe. send it up to your server using javascript and refresh the page or alter the content using ajax as needed. not pretty but possible.

2. as it seems what you want to do is identify the incoming user's country by his IP address, use the free service from maxmind. there is a tutorial at
 
I do Believe Jpadie has just provided the bets solution.

The site Jpadie posted is sure to help you out in implementing the Ip to country scheme. An will be running on your server, so it will be a hell of alot easier to implement than the external site you want to use.



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thanks u all for u reply. The point is that that external site offer other information beside country name such as city name which i am intrsted to use .I hope i be able to solve this issue.thanks
 
have a look in the pear repository. from recollection there is a class posted there that does full context geo lookups.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top