Hi Everyone

Need a simple batch file that displays only the IP address of the machine that is viewing my web app(form)

Prefer it to exclude the subnet/gateway etc and for it to be possible to be added to the database when the user enter all the required fields

I have a little problem here i have uploaded my system on server and my ip adress is showing a number incrementing from my ip that is if my ip adress is 127.0.0.0 it will show 127.0.0.1 and i really need the ip adress for my database when the user enter their details i want to see his/ip adress and it needs t be saved on the database.

There is a method of showing the ipconfig by creating a a batch file and then u name it ipconfig.bat and u have the link so that the users can click to view their ip can anyone help me with this how am i going to save that ip on my database pls help

the code im using now to sow my ip adress is

$IP=$_SERVER['HTTP_X_FORWARDED_FOR'];
if ($IP=="")
 $IP=$_SERVER['REMOTE_ADDR'];

T

    I am a little unsure of what you are asking for?

    ipconfig will report IP address (among other things) on the Windows Machine it is being run on.

    Which IP address would you like to report to the user? Their IP address or your server's IP address?

      It must show the Users IP Adress who is viewing the form, after they have entered their info it will be added to the database, it is a form where they will send their trouble tickets so i also need the ip adress of the user

        The "$IP=$_SERVER['REMOTE_ADDR'];" Shows the IP address of the person viewing the page, which is where the form is located.

        I believe that you have the right code?

          yes i can be able to do that but the server i have uploaded my system in, is giving me issue , it is just showing the wrong ip address , so i wanted help i was researching on the net and there was a way of using a batch file to get the ip address , so i was wondering if it was possible and if someone can assist me

            Try this. Here is a tutorial on using jQuery to get content from a Remote URL.

            You can send the JavaScript on the clients end to an IP Address Reporting Service.

            You can find one here that is intended for automation.

            Perhaps you could modify the JavaScript to take the information and "write" a hidden form element with the IP address.

            There is a small chance of errors, etc, depending on security settings of the browser. But if you NEED the IP address, this is what you can do.

            Otherwise, if they are on windows, you can put the following info into a .BAT file:

            @echo OFF
            ipconfig
            pause
            

            This will open the window and wait for them to press a key so they can note their IP address.

              Thikho wrote:

              t is just showing the wrong ip address

              How do you know? From your example above, I don't quite understand... are you trying to say that PHP shows "127.0.0.1" while you think your IP is "127.0.0.0" ? I'd like to know where you're getting that "127.0.0.0" from... "127.0.0.1" is the correct address for the loopback interface.

                big.nerd

                Thank you very much i think this will help me i will get back to you after going through the links you sent me .

                The users are both in windows and Linux , so which method will suit both users ??

                bradgrafelman
                I was giving an example that when i upload my files on a server i.e 10.0.0.3 , when everyone view it they see a different IP ADRESS WHICH IS 10.0.0.1

                  I'm a bit confused as to what exactly you're asking here... just to clarify, what IP address are you looking for, the client who's viewing the page, or the server on which the page resides?

                    a month later

                    I need the ip of the client viewing the page, but now it shows the same the same ip even for all clients viewing this

                    Your IP address is 10.0.0.1

                      here is my code

                      <?php
                      $IP=$_SERVER['HTTP_X_FORWARDED_FOR'];
                      if ($IP=="")
                       $IP=$_SERVER['REMOTE_ADDR'];
                      
                      echo "<div align=\"left\">Your IP address is <b>$IP</b></div>";
                      
                      ?>

                        You say that $IP=$_SERVER['REMOTE_ADDR']; is giving you the wrong IP address. It always gives the right IP address, so maybe you are looking at the wrong one. If you do an ipconfig command on Windows, or an ifconfig command on Linux, you get the local IP address, i.e. the IP address that is used on the local network. When you connect to the Internet the web server sees only your external IP address, i.e. the IP address that is issued by your ISP.

                        If you visit a site such as http://www.whatismyip.com you can see what your external facing IP address is, and you can then match this against what $IP=$_SERVER['REMOTE_ADDR']; is reporting.

                        There is only one instance I have seen in the past where several IP addresses were being reported. The local network router was set to use a range of IP addresses, so it cycled between them all very quickly, but it gave the impression that 3 very similar IP addresses were connecting to a website. This was annoying for me, as it was about the same time I was working on a visitor tracking system for websites, and it threw the results out during testing!

                          maybe its our server this side because when i uplaod it ona different server it show the right ip like on the link you have directed and i need this ip adress since my system is for sending trouble tickets I will find , but when i uplaod it on a different server its giving me the same ip so this is very stressing , the code works fine 🙂 maybe it our server i will find out do u thin the firewall can block the ip or it depends on th setting , im not good with this technical things

                            If you are running the PHP code on a local server, then it will report only the local IP address. I'm guessing now you're running the web server on your local server (hence the 127.0.0.1 loopback address) Have you tried either running the web server on another machine, or calling the web page from another machine? Failing that, can you get the script onto a web server outside of your network and test it there?

                              yes i have tried that ,and it is working fine on the other server but when i move it to the other server it doesn't work , on the local host it how this (127.0.0.1)

                                Sorry, I don't understand what you mean. Does it work when you move the script to another server? Does it work if you call the script from another server?

                                  on server a it works fine and on the local host , but when i move my script to server b it does not work it only show the same ip when viewed by different users

                                    I tihnk the best idea is moving the script to a server outside of your local network, as I think your problems stem from the fact that the IP addresses are all internal facing when you expect external facing

                                      Write a Reply...