iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-03-2009, 03:04 AM
subho's Avatar
WebProWorld Member
 
Join Date: Sep 2005
Location: India
Posts: 87
subho RepRank 0
Default Storing IP location in Mysql database

Hello all

I have a simple feedback form, from there the user inputs are getting stored in Mysql database.But I want to track my visitors IP location along with other inputs and store it into database as well. How to do it? A

ny help or tutorial would be appreciable.

Thanks in advance-
__________________
Developersouvik [Technology & creativity Spun together]
http://developersouvik.orgfree.com

Last edited by subho; 06-03-2009 at 03:14 AM.
Reply With Quote
  #2 (permalink)  
Old 06-03-2009, 10:16 AM
wige's Avatar
Moderator
WebProWorld Moderator
 
Join Date: Jun 2006
Location: United States
Posts: 2,648
wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9
Default Re: Storing IP location in Mysql database

IP addresses are generally stored as text because you can not store them as numbers without doing a lot of conversion to remove the decimals. On the form that is entering the information into the database, simply add the user IP from the environment variable, $_SERVER['REMOTE_ADDR'].
__________________
The best way to learn anything, is to question everything.
Reply With Quote
  #3 (permalink)  
Old 06-03-2009, 05:20 PM
WebProWorld Pro
 
Join Date: Jan 2008
Posts: 294
Tech Manager RepRank 1
Default Re: Storing IP location in Mysql database

You can follow Wige's advice and store the IP as a string (text). I prefer storing the IP address in decimal (integer) as it makes it easier to work with later.

I wrote a tutorial called Decimal and Binary Conversion of IP Addresses. But you can use MySQL commands to easily convert the data. For instance if you retrieved the IP you can use the inet_aton('$ip') command to convert the insert the IP Address ($ip) into decimal and then add the data into the database. You can convert the Decimal Address back to octets by using inet_ntoa.
__________________
I use Country IP Blocks as added security for my networks and servers.

Last edited by Tech Manager; 06-03-2009 at 05:24 PM.
Reply With Quote
  #4 (permalink)  
Old 08-20-2009, 11:59 AM
WebProWorld New Member
 
Join Date: Aug 2009
Posts: 21
clonfran RepRank 1
Default Re: Storing IP location in Mysql database

Would this help at all?

How-to create a simple PHP mail contact form with MySQL - The Tech Labs
__________________
MBT | MBT Shoe Reviews
Reply With Quote
  #5 (permalink)  
Old 08-26-2009, 12:35 PM
edhan's Avatar
WebProWorld Veteran
 
Join Date: Aug 2003
Location: Singapore
Posts: 716
edhan RepRank 3edhan RepRank 3edhan RepRank 3
Default Re: Storing IP location in Mysql database

Quote:
Originally Posted by Tech Manager View Post
You can follow Wige's advice and store the IP as a string (text). I prefer storing the IP address in decimal (integer) as it makes it easier to work with later.

I wrote a tutorial called Decimal and Binary Conversion of IP Addresses. But you can use MySQL commands to easily convert the data. For instance if you retrieved the IP you can use the inet_aton('$ip') command to convert the insert the IP Address ($ip) into decimal and then add the data into the database. You can convert the Decimal Address back to octets by using inet_ntoa.
Thanks! This is good resource as I never think of it. Now I can add this in my database for those login in my private access area.
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MYSQL Database Query Gracey Database Discussion Forum 3 03-30-2009 10:37 AM
i am new to mySQL Database AndrewB Database Discussion Forum 9 09-04-2007 02:42 PM
Images in a MySQL Database madmanlear Web Programming Discussion Forum 2 03-14-2007 07:15 PM
My MySQL Database Problem jazzmatazz2005 Database Discussion Forum 19 12-07-2005 09:56 AM
Setting up a MySQL Database danielle v2.1b Database Discussion Forum 11 02-05-2004 10:07 AM


All times are GMT -4. The time now is 04:23 AM.



Search Engine Optimization by vBSEO 3.3.0