sonny Posted July 24, 2009 Share Posted July 24, 2009 I have no Idea on this one, I would like to at times be able to feed a ip address into the following code, via a link, instead of using a manual form $location = GeoIP_record_by_addr($gi, $_POST["ipp"]); any idea how I can do this? Something like this below is what I need to be able to do http://domain/display.php?action=check&ip=58.61.164.141 Thanks Sonny Quote Link to comment https://forums.phpfreaks.com/topic/167340-solved-feeding-ip-address-into-an-array-via-url/ Share on other sites More sharing options...
vineld Posted July 24, 2009 Share Posted July 24, 2009 If you wish to retrieve a value from a url you should use $_GET instead of $_POST. Be sure to always validate user input. Quote Link to comment https://forums.phpfreaks.com/topic/167340-solved-feeding-ip-address-into-an-array-via-url/#findComment-882373 Share on other sites More sharing options...
sonny Posted July 24, 2009 Author Share Posted July 24, 2009 If you wish to retrieve a value from a url you should use $_GET instead of $_POST. Be sure to always validate user input. Hi I am on this now I just posted the code line as I have it from a form that's on another page I would like to feed the IP address and display results directly in the display page instead here is what I am trying to do, create a geoip lookup page that works from a manual form and also can display results via a url link, as the example I posted above will that be really hard to do? Thanks Sonny Quote Link to comment https://forums.phpfreaks.com/topic/167340-solved-feeding-ip-address-into-an-array-via-url/#findComment-882375 Share on other sites More sharing options...
lonewolf217 Posted July 24, 2009 Share Posted July 24, 2009 so basically what you have is this: Page1: form where user enters an IP Page1 will then send the IP as part of the URL to Page2 ... Page2: grab the IP from the URL, do the geo-location thingy and display the results Is that correct? If that is so, then vineld is correct. You should use the $_GET method for your form, then just grab the IP address on page2 using something like $_GET['ip'] Quote Link to comment https://forums.phpfreaks.com/topic/167340-solved-feeding-ip-address-into-an-array-via-url/#findComment-882378 Share on other sites More sharing options...
vineld Posted July 24, 2009 Share Posted July 24, 2009 That will work fine. Just a few things that don't have to do with this particular "problem". Have you purchased an IP database or do you pay for queries? In that case you may wish to validate the IP first and also restrict the number of searches. Otherwise people will eat you up alive with automatic requests Quote Link to comment https://forums.phpfreaks.com/topic/167340-solved-feeding-ip-address-into-an-array-via-url/#findComment-882379 Share on other sites More sharing options...
sonny Posted July 24, 2009 Author Share Posted July 24, 2009 That will work fine. Just a few things that don't have to do with this particular "problem". Have you purchased an IP database or do you pay for queries? In that case you may wish to validate the IP first and also restrict the number of searches. Otherwise people will eat you up alive with automatic requests Thanks for caring enough to bring that point up, Its could be really Important your right on! This not public available, I just want to be able to click a IP address which I will make a link from my hit log and display results I don't understand what you guys are saying, right now I have a very simple form page and another page that displays results, how exactly do I call a IP address result directly via a URL on the display page, thats what I need to do, maybe I am not explaining properly, can you guys show me? Thanks Sonny Quote Link to comment https://forums.phpfreaks.com/topic/167340-solved-feeding-ip-address-into-an-array-via-url/#findComment-882382 Share on other sites More sharing options...
vineld Posted July 24, 2009 Share Posted July 24, 2009 Use the get method instead of post for the form and then simply retrieve the values from both form and url as $_GET["ip"]. Of course the ip field should then have the same name as is in the query string of the url. Quote Link to comment https://forums.phpfreaks.com/topic/167340-solved-feeding-ip-address-into-an-array-via-url/#findComment-882398 Share on other sites More sharing options...
sonny Posted July 25, 2009 Author Share Posted July 25, 2009 Use the get method instead of post for the form and then simply retrieve the values from both form and url as $_GET["ip"]. Of course the ip field should then have the same name as is in the query string of the url. Works Thank you this is really good to know, now I can focus on making my code safe Sonny Quote Link to comment https://forums.phpfreaks.com/topic/167340-solved-feeding-ip-address-into-an-array-via-url/#findComment-882412 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.