Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jul 2006
    Location
    India
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question how to track visitors IP?

    Hi all.
    I am having difficulty in tracking the IP addresses of visitors on my site.
    How can I use the gethostbyaddr($_SERVER['REMOTE_ADDR']); function to track the visitors IP.

    I want to have a template in which I press a button I should see the IP of the Visitor.

    Please help me to solve this problem.

    regards,
    Amit Chouhan
    amitchouanji@gmail.com

  • #2
    Regular Coder
    Join Date
    May 2006
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just use the $_SERVER variable. The gethostbyaddress function will try to resolve that to a hostname.

    PHP Code:

    echo $_SERVER['REMOTE_ADDR']; 

  • #3
    New Coder
    Join Date
    Jul 2006
    Location
    India
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanx cubsfan,
    can u please tell me how can I use this function in a form that i am using for PST method <form action="" method="POST">
    I want to call this function when i submit it through a button.

    regards,
    Amit Chouhan
    amitchouhanji@gmail.com

  • #4
    Regular Coder
    Join Date
    May 2006
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you only want it to show when the form is posted, check if the submit button is pressed and echo it out based on that. So if you have a submit input on your form

    <input type='submit' name='submit' value='Click Me'>

    then you can do

    PHP Code:

    if ($_POST['submit']) {
      echo 
    $_SERVER['REMOTE_ADDR'];


  • #5
    New Coder
    Join Date
    Jul 2006
    Location
    India
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanx again ..
    yeah it worked.
    I am trying to learn more functions to track hits and Ip address of the visitors on my site.
    thanx for ur time .

    regards,
    Amit Chouhan,
    amitchouhanji@gmail.com


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •