Capture a IP in sign up

Want to chit chat about anything, do it here ... posting here won't increase your post count (or shouldn't!). Please do not post any "phpBB" specific topics here unless they do not fit into the category above. Do not post bug reports, feature or support requests!
Forum rules
Please do not post any "phpBB" specific topics here unless they do not fit into the category above.

Do not post bug reports, feature or support requests! No really... Do not post bug reports, feature or support requests! Doing so will make Bertie a very sad bear indeed. :(
Post Reply
paragon
Registered User
Posts: 17
Joined: Mon Jul 21, 2003 11:59 pm

Capture a IP in sign up

Post by paragon »

I am trying to learn PHP a little better and make my own scripts. I am having troubles finding out how to capture a IP on sign up and log it in the table.

BTW I like the new forums. I just hope you can disable that robotic login thing.

paragon
Registered User
Posts: 17
Joined: Mon Jul 21, 2003 11:59 pm

Re: Capture a IP in sign up

Post by paragon »

Another thing is I cant seem to read my encrypted passwords, it just doesnt work. I heard MD5 is good, what do you guys think? Thanks.

User avatar
A_Jelly_Doughnut
Registered User
Posts: 1780
Joined: Wed Jun 04, 2003 4:23 pm

Re: Capture a IP in sign up

Post by A_Jelly_Doughnut »

Yes, you can disable the "Anti robotic registration". As for IP.

Code: Select all

<?php function getIP() {
$ip;

if (getenv("HTTP_CLIENT_IP")) $ip = getenv("HTTP_CLIENT_IP");
else if(getenv("HTTP_X_FORWARDED_FOR)) $ip = getenv("HTTP_X_FORWARDED_FOR");
else if(getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR");
else $ip = "UNKNOWN";

mysql_query(INSERT user_ip INTO my_ip_table VALUES($ip));

} ?>
should do it, no waranty.

MD5 is a universal hashing method. It is really the only one around (or the only one I've seen used at least)
A_Jelly_Doughnut

paragon
Registered User
Posts: 17
Joined: Mon Jul 21, 2003 11:59 pm

Re: Capture a IP in sign up

Post by paragon »

Thanks alot man. Is there a reason why I cant get MD5 working? Do I have to change the way I login? I use sessions.

paragon
Registered User
Posts: 17
Joined: Mon Jul 21, 2003 11:59 pm

Re: Capture a IP in sign up

Post by paragon »

<? echo $ip; ?>

Should I include the IP in the same table as the users table? I have my users sign up# username and password I want to add a upload package feature later on.

Field Type Attributes Null Default Extra Action

user_id int(10) UNSIGNED No auto_increment
username varchar(20) No
PASSWORD varchar(20) No
user_ip I dont know varchar?(15?) No

I have it like this right now. I would like to add some kind of password encryption.

User avatar
A_Jelly_Doughnut
Registered User
Posts: 1780
Joined: Wed Jun 04, 2003 4:23 pm

Re: Capture a IP in sign up

Post by A_Jelly_Doughnut »

should be varchar(32) on the password field.
A_Jelly_Doughnut

paragon
Registered User
Posts: 17
Joined: Mon Jul 21, 2003 11:59 pm

Re: Capture a IP in sign up

Post by paragon »

ahhh, Thanks AGAIN! :D

User avatar
VxJasonxV
Registered User
Posts: 341
Joined: Sun Mar 02, 2003 2:51 pm
Location: Castle Rock, CO
Contact:

Re: Capture a IP in sign up

Post by VxJasonxV »

A_Jelly_Doughnut wrote:Yes, you can disable the "Anti robotic registration". As for IP.

Code: Select all

<?php function getIP() {
$ip;

if (getenv("HTTP_CLIENT_IP")) $ip = getenv("HTTP_CLIENT_IP");
else if(getenv("HTTP_X_FORWARDED_FOR)) $ip = getenv("HTTP_X_FORWARDED_FOR");
else if(getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR");
else $ip = "UNKNOWN";

mysql_query(INSERT user_ip INTO my_ip_table VALUES($ip));

} ?>
should do it, no waranty.

MD5 is a universal hashing method. It is really the only one around (or the only one I've seen used at least)
There are many more hashing/one-way encryption formats than MD5...just not really used as much :D.

Second, you messed up the code.

Code: Select all

<?php function getIP() {
$ip;

if (getenv("HTTP_CLIENT_IP")) $ip = getenv("HTTP_CLIENT_IP");
else if(getenv("HTTP_X_FORWARDED_FOR")) $ip = getenv("HTTP_X_FORWARDED_FOR");
else if(getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR");
else $ip = "UNKNOWN";

mysql_query(INSERT user_ip INTO my_ip_table VALUES($ip));

} ?>
You missed the " on the end of HTTP_X_FORWARDED_FOR
"If You Support It, They Will Come."
"Construction"

Kail
Registered User
Posts: 35
Joined: Tue Jul 22, 2003 2:45 pm

Re: Capture a IP in sign up

Post by Kail »

There are several hashing methods, you could also use PHP's crypt() function.
Styles/template designer
Former phpBB Team member
http://www.phpbb-se.com" target="_blank - phpBB på svenska!

R45
Registered User
Posts: 236
Joined: Tue Nov 27, 2001 10:42 pm

Re: Capture a IP in sign up

Post by R45 »

MD5 is just more sexy than most ^_^

Post Reply