I am trying to validate addresses input from users, where they give their street name, zip code, house number etc ...
The question is, how can I validate weather the address is valid?
The even better question would be, how can I check using the IP of the user, weather the input match the current country of the user or not, according to those informations I am gonna flash some validation errors.
Can I implement this in a Google Map for example?
Thanks
You can't.
There are simply too many edge cases, where addresses might seem wrongful, but are correct. Where I live some companies get their own zip code, also some roads do and some addresses does not have a town name.
If you want to be as precise as possible, you should ask the user to enter their address through a Google Maps auto complete field, as Google Maps knows a lot of the edge cases.
That being said, It's not accurate to check whether the users inputted address matches their origin country, as they can be behind a VPN. Also some IP addresses maps to another country than the user is actually in.
Related
I am working on an educational website in PHP Condeigniter. The project includes an option where students can sent private messages to tutors and vice versa but they are not allowed to share their contact details with each other, like phone number, skype id, home address, email etc. Is there any way in which I can control this? For example, if a user writes his phone number like 12345677, the algorithm should automatically replace it with xxxxxxxx so that the other user should not be able to view the number..
You can attempt to censor some of the text patterns with regular expressions but don't expect to get 100% of them. I don't think you can reliably censor things like skype IDs and addresses.
Also note that if they'll really want to share contact information they are going to find a way to get around your filters.
I have a list of addresses in database. I can show google from these addresses in my website but I want to make a link from these addresses. When user clicks on address It will open google map in a new tab.
Just done this for a client. If you take the following php generated link:
<?php echo 'http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q='.$placestring.'&aq=&sll=&sspn=&vpsrc=0&ie=UTF8&hq=&hnear='.$near.'&t=h&z=12'; ?>
$placestring in my code is simply the address, put through a htmlentities() routine to ensure it is a safe url. The $near variable can be used to avoid doubt if your addresses are all within a certain area - i.e. if all of the addresses are in London, you could use London as the $near variable. This helps google to provide a better match. If you have postcodes (in the UK) or a lat/long then this will massively help.
For an online ordering system, we figured that we would take the entered address and city, calculate the distance between it and each entry in a database of addresses using the Google Maps API.
However the client was told by his previous designer that he needs to use geotargeting for more accuracy. As far as I know, geotargetting is only accurate in getting the user's country, but definitely not precise location.
Is there a problem with the address+city method? And is there any truth to the geotargetting method?
Geo-targeting will provide you with the precise location (coordinates) of the user, if they choose to share it.
You can use the coordinates with Google Maps API to then calculate the distance in the same manner you planned with address of the user or the restaurant. (Google converts any address to a coordinates in it's calculations.)
There is no problem with your address+city method, but it may be easier for users to just share their current location... and not have to enter a current address+city.
Address+city would need to be a fallback if the user is not willing to 'share their current location' via geo-targeting.
First of all thanks to all ....
I read that i can use the free IP geolocation webservice to get Country name from an Ip address. But how i get the response to my site , Actually this is what i look , In my site there is a need of displaying the country name from Ip address. Can uou please tell in detail... How can i display the country Name from that site ..
geoip_country_code_by_name can give you the country for an arbitrary IP address or hostname (not just the one from the current visitor as apache_note("GEOIP_COUNTRY_NAME") does), it uses the same MaxMind database. There is also the geoip_country_name_by_name function if you want the full country name rather than the ISO code.
http://www.maxmind.com/app/php
You need to install the php module and then use the following code to get the country name:
$country_name = apache_note("GEOIP_COUNTRY_NAME");
Have checked this functionality in Oplim? It is free for up to 500k pageviews, and you can set your code and custom condition (country, or even areas such as all the EU).
Disclosure: I am among the service developers.
my problem is i want to show my registered site user on to google map but dont know how to locate the user, means i dont know the latitude and longitude of every user . I am a newbie in google map so plz help
Thanks a ton
What location data do you have for your users? Cities, states, countries?
You might want to have a look at Google's Geocoding APIs.
there are two possible ways of doing this.
Ask the user to search a google map and place themselves on it. Look here for an idea on how to do this http://www.designing4u.de/2008/08/google-maps-jquery-and-xml-saving-markers-with-user-input/
Use an IP to Location database to find out the location based on their IP. Look here for how to do this http://www.ip2nation.com/ip2nation
There is no way to reliably locate a user using their IP address. However if you are developing for a mobile device it may be possible to acquire their GPS coordinates. Or you could require them to enter an address and place a point on the map from that address with geocoding.
If you are collecting the address of each registered user, you can get the latitude and longitude on the server-side through the Google Maps HTTP Geocoding Service.
You would use the following HTTP request:
http://maps.google.com/maps/geo?q=Oxford+Street,+London&output=csv&sensor=false
Simply change the q parameter with your user's address.