-1

I am making a registration page on my website.

I don't want my users to type their own country. I am wondering how to make a PHP/JS/jQuery script that will work with this:

<input type="hidden" name="country" value="!!COUNTRY CODE HERE!!">

1 Answers1

0

If you want to get the users country, you're going to need to do it with (qualified) guess using their IP address - see this question and answer for an easy PHP-script for doing so.

If this is for a user registration page and the users country is important to get right, though, I would recommend a dropdown-menu where the users can choose the country for themselves instead. Guessing which country a user is from based on their IP isn't guaranteed to be correct every time. Some people might be using static IP addresses or VPNs or some proxy of sorts, which would give you a wrong result.

Community
  • 1
  • 1
Tobias Roland
  • 1,182
  • 1
  • 13
  • 35