simple php help..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xxweekxx
    Confirmed User
    • Oct 2002
    • 6780

    #1

    simple php help..

    i have a mortgage form that posts submitted data to mysql.. however, somehow when users post in my mysql dbase it shows their ip as my server ip..

    im using $_SERVER['REMOTE_ADDR'] but it still shows my server ip for every submission..

    What do you suggest (btw this is shared hosting)
    _________________
    I am the best
  • ScriptWorkz
    Confirmed User
    • Jul 2007
    • 274

    #2
    Originally posted by xxweekxx
    i have a mortgage form that posts submitted data to mysql.. however, somehow when users post in my mysql dbase it shows their ip as my server ip..

    im using $_SERVER['REMOTE_ADDR'] but it still shows my server ip for every submission..

    What do you suggest (btw this is shared hosting)
    it sounds like maybe your doing the post from your server instead of the actual client, if so, and your using a server side script to actually post the form then the solution is to pass $_SERVER["REMOTE_ADDR"] as a variable in the form (so it gets set as a hidden input in the form), and then use that variable instead of $_SERVER["REMOTE_ADDR"] in your post processing code.

    Comment

    • xxweekxx
      Confirmed User
      • Oct 2002
      • 6780

      #3
      what do u mean im doing post from my server? when i upload any simple php script and do server[remote_addr] , and echo it, it gives me server ip..
      _________________
      I am the best

      Comment

      • Masterchief
        Confirmed User
        • Jun 2006
        • 530

        #4
        your host is probably using some sort of caching/proxy server in front of the main web server. run get_defined_vars to see if the real IP is set elsewhere

        Comment

        • bDok
          Confirmed User
          • Feb 2005
          • 1917

          #5
          Originally posted by xxweekxx
          what do u mean im doing post from my server? when i upload any simple php script and do server[remote_addr] , and echo it, it gives me server ip..
          exactly it's echoing the remote_addr at that point. When you post to a form you probs are grabbing the remote_addr at that point from the .php that's responsible for handling the user input.

          the advice that was given will sort you out. something like

          Code:
          <input name="remoteip" type="hidden" value="<?php print $REMOTE_ADDR; ?>">
          then in the part that handles the post pull the remoteip by parsing it from the name remoteip.
          =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
          Warriors come out to plaAAaayyy!
          =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

          Comment

          • ScriptWorkz
            Confirmed User
            • Jul 2007
            • 274

            #6
            Originally posted by Masterchief
            your host is probably using some sort of caching/proxy server in front of the main web server. run get_defined_vars to see if the real IP is set elsewhere
            Yeah, my advise was just my first take on the matter, i thought maybe you had a php script doing the actual posting to your processing code, if not i'd check out this solution.

            Comment

            • Masterchief
              Confirmed User
              • Jun 2006
              • 530

              #7
              Originally posted by bDok
              exactly it's echoing the remote_addr at that point. When you post to a form you probs are grabbing the remote_addr at that point from the .php that's responsible for handling the user input.

              the advice that was given will sort you out. something like

              Code:
              <input name="remoteip" type="hidden" value="<?php print $REMOTE_ADDR; ?>">
              then in the part that handles the post pull the remoteip by parsing it from the name remoteip.
              That's incredibly stupid, why would you give the ability for clients to manipulate their ip addresses?

              and why are you using code that depends on register globals being on?

              Comment

              • xxweekxx
                Confirmed User
                • Oct 2002
                • 6780

                #8
                i tried to call it by adding this to my main php index page that has the form..

                <input type="hidden" name="ip" value="$_SERVER[REMOTE_ADDR]">

                and it doesnt work. Just shows the same stuff when i view source. i wanna get that variable and pass it on.. but it just shows me $SERVER[REMOTE_ADDR]"> and not actual ip..
                _________________
                I am the best

                Comment

                • xxweekxx
                  Confirmed User
                  • Oct 2002
                  • 6780

                  #9
                  added <input name="remoteip" type="hidden" value="<?php print $REMOTE_ADDR; ?>"> to my code..

                  when i open page and view source, comes up blank.. nothing there
                  _________________
                  I am the best

                  Comment

                  • xxweekxx
                    Confirmed User
                    • Oct 2002
                    • 6780

                    #10
                    ok i tried <input name="remoteip" type="hidden" value="<?php print $REMOTE_ADDR; ?>"> and when i view source i still see server ip?
                    _________________
                    I am the best

                    Comment

                    • footmonkey
                      Confirmed User
                      • Nov 2005
                      • 639

                      #11
                      Check out your phpinfo()

                      That's going to show you all the variables. If you're getting the wrong value you can see what you want from the phpinfo and change your script.

                      Comment

                      • xxweekxx
                        Confirmed User
                        • Oct 2002
                        • 6780

                        #12
                        maybe ill host a lil svcript to grab ip on a diff server and then include it on this one.. will this work? if so how?
                        _________________
                        I am the best

                        Comment

                        • xxweekxx
                          Confirmed User
                          • Oct 2002
                          • 6780

                          #13
                          i looked but it shows remote_addr as server ip still.. come on guys what can i do
                          _________________
                          I am the best

                          Comment

                          • xxweekxx
                            Confirmed User
                            • Oct 2002
                            • 6780

                            #14
                            bumppppppppp
                            _________________
                            I am the best

                            Comment

                            • xxweekxx
                              Confirmed User
                              • Oct 2002
                              • 6780

                              #15
                              bump again
                              _________________
                              I am the best

                              Comment

                              • BigBen
                                Confirmed User
                                • Nov 2004
                                • 2299

                                #16
                                Ask your host...

                                Comment

                                • jimbona
                                  Confirmed User
                                  • Jan 2007
                                  • 190

                                  #17
                                  if a proxy is a problem use dmxzone.com/ShowDetail.asp?NewsId=8100

                                  or use $_ENV["REMOTE_ADDR"] (environment IP)
                                  if none of these show the user IP, try on another PC, your ISP might be reporting back incorrect IP's.
                                  Thanks
                                  Paul
                                  Thunder-Ball.net - Member

                                  Comment

                                  • lb_vee
                                    Confirmed User
                                    • May 2004
                                    • 886

                                    #18
                                    If you can test from a known IP, what I would do is generate a dump of the environment variables and see where your IP shows up. Then use that instead of the remote host (which isnt recommended but might works).

                                    The best solution (like others have said) would be to contact the ISP to see why your IP is coming back. Probably some routing issue on the box itself.

                                    Comment

                                    Working...