www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: IP Address

  1. #1
    Join Date
    Apr 2003
    Location
    Nevada
    Posts
    411

    IP Address

    Is there a way to collect someone's IP address when they submit a form, then display that IP address in your e-mail that you get from that form... I am just asking because people have been using some unnesessary language in forms that are meant for good means... This way I can bann the user that has violated such viciousness.
    WARNING: non-exposure to the Son can cause burning!

  2. #2
    Join Date
    May 2003
    Posts
    550
    If you are using Pyro's email script to process the form, just add this to your form.

    <input type="hidden" value="<?php echo $_SERVER['REMOTE_ADDR']?>">

    If someone really wanted to, they could edit the source of your page and remove that line, then use the form, but I doubt they will do that. If they do , post back and I'll give you a line to add to the script itself.

  3. #3
    Join Date
    Apr 2003
    Location
    Nevada
    Posts
    411
    what is the one where they can't use it
    WARNING: non-exposure to the Son can cause burning!

  4. #4
    Join Date
    May 2003
    Posts
    550
    <?PHP

    $subject = "Feedback";
    $headers = "From: Form Mailer";
    $forward = 1;
    $location = "feedbackthankyou.html";
    $addresses = array("webmaster@crosspoint.org","dvaughan@crosspoint.org","lhale@crosspoint.org");

    $date = date ("l, F jS, Y");
    $time = date ("h:i A");
    $IP = $_SERVER['REMOTE_ADDR'];
    $msg = "This form was submitted on $date at $time.\n\n";
    $msg = $IP . $msg
    foreach ($_POST as $key => $value) {
    $msg .= ucfirst ($key) ." : ". $value . "\n";
    }

    foreach ($addresses as $email) {
    mail($email, $subject, $msg, $headers);
    }
    if ($forward == 1) {
    header ("Location:$location");
    }
    else {
    echo ("Thank you for submitting our form.");
    }

    ?>

  5. #5
    Join Date
    Apr 2003
    Location
    Nevada
    Posts
    411
    Sorry, had to eat lunch... thanks for the script
    WARNING: non-exposure to the Son can cause burning!

  6. #6
    Join Date
    May 2003
    Posts
    550
    No prob

  7. #7
    Join Date
    Jun 2003
    Posts
    151
    Why won't this work for me..

    PHP Code:
    <?
    $IP 
    $_SERVER['REMOTE_ADDR']; 
    mail("email@hotmail.com","Subject..""IP: $IP\n");
    ?>
    I even tryed adding this
    <input type="hidden" value="<?php echo $_SERVER['REMOTE_ADDR']?>">
    to my from, but nothing.... I get email and all but no IP.. It's just empty after "IP:" text...
    Extreme

  8. #8
    Join Date
    Jun 2003
    Location
    Guildford, UK
    Posts
    153
    I copied and pasted exactly the code that you entered below, and it gave me the correct IP address. Maybe your server isn't configged correctly or you are behind some proxy server ?(plucking at straws here...)

  9. #9
    Join Date
    Apr 2003
    Location
    Nevada
    Posts
    411
    I am registered w/ www.globat.com

    And, I got the e-mail when I didn't have the IP address... so what is happening?
    WARNING: non-exposure to the Son can cause burning!

  10. #10
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    You could try this:

    PHP Code:
    <?
    $IP 
    $_SERVER['REMOTE_ADDR']; 
    mail("email@hotmail.com","Subject..""IP: ".$IP."\n");
    ?>

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  11. #11
    Join Date
    Dec 2002
    Location
    Canada, eh?
    Posts
    228
    also, if you/your server is running less than PHP 4.1.0 (servers usually tell you what version they run), superglobals wont work...

    try $HTTP_SERVER_VARS['REMOTE_ADDR'] instead of $_SERVER['REMOTE_ADDR'] and see if that makes a difference...and check here for more details...

  12. #12
    Join Date
    Jun 2003
    Posts
    151
    Yeah, it works this way....Thanks everyone...
    Extreme

  13. #13
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Which way?

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  14. #14
    Join Date
    Jun 2003
    Posts
    151
    This:

    try $HTTP_SERVER_VARS['REMOTE_ADDR'] instead of $_SERVER['REMOTE_ADDR']
    I guess my webserver was an error... Can someone check this out and see if any of this can be updated so I can work with PHP without a problem.... This is what they have now...
    Apache/1.3.19 (Unix) (Red-Hat/Linux) mod_ssl/2.8.1 OpenSSL/0.9.6 DAV/1.0.2 PHP/4.0.4pl1 mod_perl/1.24_01
    Last edited by Extreme; 07-18-2003 at 06:37 PM.
    Extreme

  15. #15
    Join Date
    Dec 2002
    Location
    Canada, eh?
    Posts
    228
    well its just that your server has a slightly out-of-date version of PHP - 4.0.4 instead of 4.1.0, which is when they introduced the $_SERVER variables...

    by just using $HTTP_SERVER_VARS, it will achieve the same effect, only slightly more of a strain on the fingers, thats all

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles