Page 1 of 1

help with logging ip address during registration

Posted: Fri Oct 31, 2008 7:04 pm
by rxpghost
Hello,

I would like to log the ip address of people that register on my site. I have created the database table for this but need the php code to get it logged. On the registration page I have a form that posts the data from each field to the db. I am new to php so the simplest terms would be appreciated.

Thanks in advance

Re: help with logging ip address during registration

Posted: Fri Oct 31, 2008 7:36 pm
by Syntac

Code: Select all

echo $_SERVER["REMOTE_ADDR"]; // Should print the client's IP address

Re: help with logging ip address during registration

Posted: Fri Oct 31, 2008 9:32 pm
by rxpghost
thanks for the quick reply. I want something that will post the ip address in the database table "ip". Any ideas on how to do this?

Re: help with logging ip address during registration

Posted: Fri Oct 31, 2008 10:00 pm
by omniuni
How is your database structured? Otherwise, check this link:

http://www.tizag.com/mysqlTutorial/mysqlinsert.php

Re: help with logging ip address during registration

Posted: Fri Oct 31, 2008 11:38 pm
by rxpghost
this would be the db query but i just used the mysql wizard to create the table

Code: Select all

CREATE TABLE `ip` (
`id` int(5) NOT NULL auto_increment,
`ip` varchar(50) NOT NULL default ”,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;
one post on another site looks about right but I always get errors when I insert that code into my form.

Code: Select all

<?php
$ip = $_SERVER['REMOTE_ADDR'];
$sql = “INSERT INTO `ip` ( `id` , `ip` ) VALUES ( ”, ‘$ip’)”;
$query = mysql_query($sql);
 
print “Logged: $ip”;
?>

Re: help with logging ip address during registration

Posted: Sat Nov 01, 2008 12:37 am
by rxpghost
ok I figured out how to log the ip address. Now I have two other things to figure out for my login system. First I need to know how to replace the password that people type to Astrix ***** instead of showing the actual password. Also I need to add "verify email" and "verify password" fields and have them compare to each other. Again, I appreciate any help that you can offer.

Re: help with logging ip address during registration

Posted: Sat Nov 01, 2008 7:18 am
by omniuni
starring the password is done client-side:

Code: Select all

 
<input type="password" size="30" />
As for comparing, submit on post something like "pass1" and "pass2" and and just use PHP's comparator to see if they're the same, otherwise, reload the page, and display a warning that they did not match.

Re: help with logging ip address during registration

Posted: Sat Nov 01, 2008 3:19 pm
by rxpghost
I don't understand how it's done on the client side. I have had the login system up and running and it doesn't star the password. I've checked it from several computers and still the same result. Can you explain in more detail how to compare the password, confirm password? Thanks in advance.

Re: help with logging ip address during registration

Posted: Sat Nov 01, 2008 3:45 pm
by baoky
Google was invented for a reasonImage

Re: help with logging ip address during registration

Posted: Sat Nov 01, 2008 4:18 pm
by rxpghost
Wow what a worthless comment. It speaks to your character that you would take the time to register just to post an insulting comment. Thank you to everyone else that has been helpful.

Re: help with logging ip address during registration

Posted: Sat Nov 01, 2008 5:30 pm
by s.dot

Code: Select all

<input type="password" name="passwordFieldName">
will 'star' the password

to compare that the passwords match, you need two HTML fields for entering the passwords.

Code: Select all

<p>Password: <input type="password" name="password" /><br />
Confirm Password: <input type="password" name="passwordConfirm" /></p>
And to check them in PHP:

Code: Select all

if ($_POST['password'] != $_POST['passwordConfirm'])
{
    die('Your passwords do not match.');
}
Here's a good form tutorial: http://www.htmlgoodies.com/tutorials/fo ... hp/3479121

Re: help with logging ip address during registration

Posted: Sat Nov 01, 2008 6:04 pm
by rxpghost
Many thanks Scottayy, that's exactly what I was looking for.

Re: help with logging ip address during registration

Posted: Sat Nov 01, 2008 7:14 pm
by VladSun
rxpghost wrote:Wow what a worthless comment.
I do second baoky's opinion!
All of your simple questions in your thread are "google answerable".

You should start "learn & think", instead of "copy & pasting" ;)