Showing IP Address of the visitor

Ask about a PHP problem here.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Showing IP Address of the visitor

Post by jacek »

An iframe is not the best solution at all.

$_SERVER['REMOTE_ADDR'] is the same as any other variable, so you can use it in an INSERT query to store the IP of the user writing the post, or use it somewhere on the page to display the IP of the user browsing the page.

The reason your eval method did not work was that you (apparently) stored the eval() call in the database too, when you were meant to use eval() on the value that was already stored in the database.
Kamal wrote:Well what I would do is instead of the PHP in there, I put ##IP## or something like that, then do:
$post_body = str_replace('##IP##', $_SERVER['REMOTE_ADDR'], $post_body);
Then the IP will be in place of ##IP##
If you have to store the full page in the table, then this would be the best solution.
Image
User avatar
Kamal
Posts: 123
Joined: Fri May 06, 2011 10:45 am
Contact:

Re: Showing IP Address of the visitor

Post by Kamal »

jacek wrote:If you have to store the full page in the table.
I think that's what he did
Post Reply