Is it best practice to prompt users to input their postal code for location-based information on a website, rather than relying solely on IP-based detection?

It is best practice to prompt users to input their postal code for location-based information on a website, rather than relying solely on IP-based detection. This is because IP-based detection can sometimes be inaccurate or unreliable, especially for users accessing the website through a VPN or proxy server. By prompting users to input their postal code, you can ensure more accurate location-based information.

// Prompt users to input their postal code for location-based information
<form action="process_location.php" method="post">
    <label for="postal_code">Enter your postal code:</label>
    <input type="text" id="postal_code" name="postal_code">
    <input type="submit" value="Submit">
</form>