user registration help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: user registration help

Post by flying_circus »

What have you tried to fix the problem?
khuzema
Forum Newbie
Posts: 10
Joined: Thu Mar 18, 2010 3:32 pm

Re: user registration help

Post by khuzema »

hi

You may think that you would store an IP address as a VARCHAR(15) field and you could, but this is not the most efficient way to store IPs. Instead you could use an INT. please remember though that you must use an INT UNSIGNED or IPs with the first octet higher than 127 will not be stored properly.

To use an INT field you must convert the IP address to numbers as you cannot store the periods in an INT field. To do this we use a MySQL command called INET_ATON(). All you need to do is provide an IP address and it will be converted to a numeric value. The IP address may be a 32-bit or 128-bit addresses.

An example command might be this:

Code: Select all

INSERT INTO user_auth(remote_addr) VALUES(INET_ATON(‘127.0.0.1′));
Thanks........
Sephern
Forum Commoner
Posts: 73
Joined: Sun Jan 04, 2009 4:44 pm

Re: user registration help

Post by Sephern »

Code: Select all

INSERT INTO user_auth (column1, column2, column3) VALUES ('column1val', 'column2val', 'column3val')
If you're getting any SQL errors, I just check the w3 site to check that I'm writing it correctly. ;x
rlthompson
Forum Newbie
Posts: 13
Joined: Sun Mar 21, 2010 1:59 pm

Re: user registration help

Post by rlthompson »

I got it, thanks to everyone for the very helpful tips.
Post Reply