notset4life
7-31-08, 01:19 PM
I am trying to capture a user's IP and add it to a database from a PHP web page registration form.
I added this to the form:
<input type="hidden" name="ip_address" value="<? $ip = getenv("REMOTE_ADDR"); print $ip; ?>">
The "value" actually shows the IP address on the page when used elsewhere, so I assumed the hidden form here would pick it up.
After submission, I insert $ip_address into database - but it comes up EMPTY. No data is added to my IP field.
------------------------------------------------------------------------------------------------------------------------------------------------------
UPDATE: I just figured it out. In MYSQL database, I had VARCHAR as the field TYPE. I changed it to INT, but that produces a 5 digit number.
I need it to format in the database as the full ip address, - So to settle this, what is the best field TYPE to use for an IP address? - INT,Text,Double?
thanks again
I added this to the form:
<input type="hidden" name="ip_address" value="<? $ip = getenv("REMOTE_ADDR"); print $ip; ?>">
The "value" actually shows the IP address on the page when used elsewhere, so I assumed the hidden form here would pick it up.
After submission, I insert $ip_address into database - but it comes up EMPTY. No data is added to my IP field.
------------------------------------------------------------------------------------------------------------------------------------------------------
UPDATE: I just figured it out. In MYSQL database, I had VARCHAR as the field TYPE. I changed it to INT, but that produces a 5 digit number.
I need it to format in the database as the full ip address, - So to settle this, what is the best field TYPE to use for an IP address? - INT,Text,Double?
thanks again