Jump to content

IP Address

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
Guest_NeedHelp_*

Guest_NeedHelp_*
  • Guests
I need to get the IP Address of my visitors and write it to a database or file. Can anyone give me an example???

#2
RobSoftware

RobSoftware

    Programmer

  • Members
  • PipPipPipPip
  • 143 posts

<?php 

$file = "iplog.txt"; 


$fp = fopen($file, "a+"); 

fwrite($fp, $_SERVER["REMOTE_ADDR"] ."\n"); 

fclose($fp); 


?> 


#3
Ronin

Ronin

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 309 posts

RobSoftware said:


<?php 

$file = "iplog.txt"; 


$fp = fopen($file, "a+"); 

fwrite($fp, $_SERVER["REMOTE_ADDR"] ."\n"); 

fclose($fp); 


?> 

Do you have any idea how to write to a mysql database, i would like to know how that works.

#4
Lop

Lop

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,172 posts

Ronin said:

Do you have any idea how to write to a mysql database, i would like to know how that works.

After you've connected to the database you could do:


$query = "INSERT INTO tbl_name VALUES ($_SERVER["REMOTE_ADDR"] )";

mysql_query($query);