(if you're unfamiliar with sql queries the part from INSERT INTO to VALUES (cid, nid, uid...) are the columns we want to change. The values that will go into the columns are all the $variables and they are in the same order as the columns were listed above. The "hostname" row was the 8th one listed so the 8th variable ($_SERVER['REMOTE_ADDR']) is what gets put in the hostname column.)
The PHP manual is your friend :-)
Hi sisyphus,
Have a look at the PHP manual and what it says about "PHP: Predefined Variables".
In this case
<?php$userip = $_SERVER['REMOTE_ADDR'];
?>
should give you what you are looking for.
Regards,
Christian Larsen
thanks. but the table
thanks. but the table comments has a field hostname. then there must have a variable inside drupal to store the user's ip address.
comment module does the same
Drupal 5's comment module uses the REMOTE_ADDR value as well. This code is the query that creates the comment's row in the database:
db_query("INSERT INTO {comments} (cid, nid, pid, uid, subject, comment, format, hostname, timestamp, status, score, users, thread, name, mail, homepage) VALUES (%d, %d, %d, %d, '%s', '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s')", $edit['cid'], $edit['nid'], $edit['pid'], $edit['uid'], $edit['subject'], $edit['comment'], $edit['format'], $_SERVER['REMOTE_ADDR'], $edit['timestamp'], $edit['status'], $score, $users, $thread, $edit['name'], $edit['mail'], $edit['homepage']);(if you're unfamiliar with sql queries the part from INSERT INTO to VALUES (cid, nid, uid...) are the columns we want to change. The values that will go into the columns are all the $variables and they are in the same order as the columns were listed above. The "hostname" row was the 8th one listed so the 8th variable ($_SERVER['REMOTE_ADDR']) is what gets put in the hostname column.)