Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 8 of 8
  1. #1
    Senior Member krazy's Avatar
    Join Date
    Apr 2003
    Location
    California
    Posts
    543
    Member #
    1078
    been a long time since i been here. heh

    i got a form, i want it to send the submitters IP # along with message. any1 know the code line?
    Ad space - for sale, $19.95/month

  2.  

  3. #2
    Senior Member seanmiller's Avatar
    Join Date
    Sep 2003
    Location
    Glastonbury, UK
    Posts
    868
    Member #
    3263
    Liked
    1 times
    Depends what you are using server side to process your form.

    The php variable $REMOTE_ADDR contains the user's IP address. Easiest way is to process it server side when the user submits the form, but if you are using formmail or similar you could just as easily make the form itself a php page and pre-populate a hidden field with this variable.

    Sean

  4. #3
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Use $_SERVER['REMOTE_ADDR'] instead of $REMOTE_ADDR as it is deprecated.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  5. #4
    Senior Member krazy's Avatar
    Join Date
    Apr 2003
    Location
    California
    Posts
    543
    Member #
    1078
    $REMOTE_ADDR
    works fine but
    $_SERVER['REMOTE_ADDR']
    gives me an error:
    Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/virtual/site20/fst/var/www/html/csend.php on line 57


    err, nvm, fixed it. i think. heh.
    Ad space - for sale, $19.95/month

  6. #5
    Senior Member seanmiller's Avatar
    Join Date
    Sep 2003
    Location
    Glastonbury, UK
    Posts
    868
    Member #
    3263
    Liked
    1 times
    Deprecated... isn't that just dandy?

    I have an up-to-date manual (published this year) that tells me what to write in PHP and it gives the $REMOTE_ADDR as the way to do it... whilst it is fine for standards bodies to "change their mind", the fact is that whilst manuals exist that teach in a certain way then they will continue to support a certain way of thinking.

    And I have to say that $REMOTE_ADDR is far far nicer than $_SERVER['REMOTE_ADDR']

    Sean

  7. #6
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    All superglobals (except, ironically, for $GLOBALS) now begin with $_. Anything else is deprecated. Not to sound arrogant but I'm fairly sure the book is wrong.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  8. #7
    Senior Member skrlin's Avatar
    Join Date
    Apr 2003
    Location
    Illinois
    Posts
    562
    Member #
    1063
    I've always used
    PHP Code:
    getenv("REMOTE_ADDR"
    and it's worked fine.
    - Brian

  9. #8
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    I use getenv( ) fairly often in my scripts. Without having to worry about what is deprecated and what is not.

    I believe filburt meant to emphasize the fact that "register_global" feature of PHP is recommended to be set to "off". Not that "$REMOTE_ADDR" per se is deprecated, because it isn't, that's just a variable name. Setting "register_global" to "on" parses the Superglobal arrays into variables, i.e. $_SERVER['REMOTE_ADDR'] into $REMOTE_ADDR.

    Read this for more details: http://us2.php.net/manual/en/securit...terglobals.php

    And seanmiller, a published book cannot be more up-to-date than PHP.net manual.
    There and Back Again :Ogre:


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:46 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com