We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4466
    • 14 Posts
    i need to log the IP address of the person thats filling out the form.

    i would love to have it show on the page and be sent by the report.

    i have looked and looked but cant find any info Re this.

    -Thanks for reading smiley
      • 36416
      • 589 Posts
      Quote from: cadmax at Jul 01, 2010, 02:04 AM

      i need to log the IP address of the person thats filling out the form.
      i would love to have it show on the page and be sent by the report.

      This piece of code is default OnBeforeSent handler for our contact forms:
      <?php
      function efOnBeforeMailSent(&$fields) {
       global $modx;
        $fields['site_url'] = $modx->config['site_url'];
        $fields['site_name'] = $modx->config['site_name'];
        if (isset($_SERVER['REMOTE_HOST'])) {
          $fields['ip_calc'] = $_SERVER['REMOTE_HOST']." (".$_SERVER['REMOTE_ADDR'].")";
        } else {
          $fields['ip_calc'] = gethostbyaddr($_SERVER['REMOTE_ADDR'])." (".$_SERVER['REMOTE_ADDR'].")";
        }
        $fields['cli_calc'] = $_SERVER['HTTP_USER_AGENT'];
        $fields['question_calc'] = wordwrap($fields['question'], 75);
        return true;
      }


      Usage example (inside eForm templates):
      ...
      Message from: [+ip_calc+] ([+cli_calc+])
      ...
      
        • 4466
        • 14 Posts
        so you are using that inside a chunk or.....? thanks.

        it looks like that what i was looking for. sorry i’m still new at this.
          • 36416
          • 589 Posts
          Quote from: cadmax at Jul 01, 2010, 03:38 AM

          so you are using that inside a chunk or.....? thanks.

          ...events: http://wiki.modxcms.com/index.php/EForm#Events