Menu

How to log IP address/location of submitter

Help
maviblue
2008-09-11
2013-06-03
  • maviblue

    maviblue - 2008-09-11

    Hi,
    I need to add some code to my form to log the submitter's IP address or location.  It could be sent to me alongside the other form information.

    Can anyone advise how to do this?

    Many thanks in advance
    Mavi

     
    • maviblue

      maviblue - 2008-09-21

      Ok I made it work myself like this:

      1) I added this code to between the form tags on the form page and saved as .php type file:

      <?php
      $ipi = getenv("REMOTE_ADDR");
      ?>
      <input type="hidden" name="ip" value="<?php echo $ipi ?>" />

      2) On the processer file, I added this to the variables at the start:

      $ip = $_POST['ip'];

      and this to the part to be printed out in the email sent:

      Additional Info : " . $_POST['ip'] . "

       
    • Jay

      Jay - 2008-10-25

      I am Newbie when it comes to adding/Editing code. Can you please tell me exactly where to add these two scripts? You said to add "to between the form tags and the form page and saved as .php" I am not sure what this means or what to do. I am fairly experienced with editing the process.php and changing sender name and Subject Title. If you could please clairfy where to add the code or what file to create, it would help me tremendously! Any information is much appreciated.

       
    • Darren

      Darren - 2008-10-28

      Awesome job maviblue...it works great. Thank you very much.

      phyrex: open form.html and edit the source code (open it with Notepad or something)

      Look for <form>

      blah, blah blah

      blah blah blah

      blah, blah blah

      blah blah blah
      </form>

      Enter: <?php
      $ipi = getenv("REMOTE_ADDR");
      ?>
      <input type="hidden" name="ip" value="<?php echo $ipi ?>" />

      in one of the blank lines between the other code:

      <form>

      blah, blah blah

      blah blah blah
      <?php
      $ipi = getenv("REMOTE_ADDR");
      ?>
      <input type="hidden" name="ip" value="<?php echo $ipi ?>" />
      blah, blah blah

      blah blah blah
      </form>

      then SAVE the form.html as form.php. Now upload the form.php to your site replacing form.html

      Then open processor.php with notepad and do what mavibue says to do with that.

      good luck,
      darren

       
    • Jay

      Jay - 2008-10-31

      Thanks darren_ =) Very helpful for a newbie like me. Much appreciated!

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.