What is the most effective way of getting a user's IP with PHP?

Which function should I use?

Thanks!

    $_SERVER["REMOTE_ADDR"]  /  $GLOBALS["REMOTE_ADDR"]
    

      Thanks.

      The script I am is server-intensive, so I have developed a way to ensure that each IP can only run it once every 2 minutes. I am using javascript to make sure that they are running the page through the real site (NOT a proxy), so I have their real IP.

      Is there any way in PHP to check if the user has javascript enabled? (as otherwise they can use a proxy that filters javascript).

        Nope. php runs server side so cant do anything on the client.

          Is it possible to see a sample of this script that ensures you are getting the real ip_address of a person and not a false one run throguh a proxy? I am having problems with scammers from using fake ip addresses. Thanks in advance!

            chatch the clients ip adress with javascript (window.location.host) , and write it into an <input type = hidden>

            (btw: what is a scammer? am not native english)

              I'm not familiar with java, would you please show me an example of how I would combine it with php? It would be an enormous help to me.

              A scammer is slang for a scam artist, someone who is trying to trick someone out of money under false pretenses. I am having problems with scammers from Nigeria that are using false IP addresses to get into my website and trick members out of their money.

              Thank you for any help that you can give me on this.

              Owen The Samoan

                heres a small script for getting the ip

                <script>
                
                /* There are a few instances in which the browser cannot ascertain the user's address, so we will instruct the browser to ignore errors by setting the onerror handler to null: */
                window . onerror = null;
                
                /* We will also give hostaddress and hostname a default value in case the address look-up fails: */
                hostaddress = hostname = "(unknown)";
                
                /* Now we will try to gather the host information: */
                localhost = java . net . InetAddress . getLocalHost ();
                hostaddress = localhost . getHostAddress ();
                hostname = localhost . getHostName ();
                
                /* The Java methods used above are capable of throwing exceptions. When Java exceptions occur within JavaScript, the script body is aborted. In order to make sure that the following statements get a chance to execute, we must include them in a separate script body: */
                
                </script>

                and this to show the ip

                <script>
                
                document . writeln ("<p>Your IP address is <b>" + hostaddress + "</b>.</p>");
                
                </script>

                however i don't know how you would put that into a hidden text field , something probably like <input name="hostip" type="hidden" value="document.write('hostaddress');" />

                tho that does not work .

                  ok, I tried using this script to check my own ip address first but I keep getting "Your IP address is (unknown)". Is there anything else I need to add to this script? I appreciate the help.

                    Write a Reply...