Users IP address added to the form

Discussion in 'HTML & Website Design' started by Kezi, Jul 14, 2008.

  1. #1
    Trying to get the users IP address added to the forms they send. I currently use Matts FormMail - I assume I'm not able to do it with that ?

    If not, what is the best form of code to achieve that please ? and the safest from spammers please ?

    Any help appreciated.

    Kezi.
     
    Kezi, Jul 14, 2008 IP
  2. bavington

    bavington Peon

    Messages:
    74
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi There,

    Simply add this

    To The PHP, and this to the email echo:

    I'm not familiar with Matts Formmail, so if my solution is tricky, send me through private message the URL, and I will see if I can direct you how to slot it in.

    James.
     
    bavington, Jul 14, 2008 IP
  3. Kezi

    Kezi Active Member

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #3
    Hi James,

    Apologies, have had problems logging in, but many thanks for your help on this, I have checked, and double checked thru the form, but can't seem to see where that code would go :confused: The URL (thought it would be ok to post here) is http://www.011005.com/form The vers of php on the server is 5, and the page does have the php extn

    The cosmetic part of it will get more attention, which I can do, but could really do with a little help on making the form to be as safe as possible from the spammers, (w/o captchas), and for the users IP address to be part of the received form.

    Open to any comments at all, to make the form better in any way.

    Any help very much appreciated.

    Kezi.
     
    Kezi, Jul 19, 2008 IP
  4. Cri2T

    Cri2T Peon

    Messages:
    104
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Add this inside the form tag:

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

    This should do the trick, though you could just get the IP address on the next page... so sending it though the form doesn't make alot of sense.
     
    Cri2T, Jul 19, 2008 IP
  5. Kezi

    Kezi Active Member

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #5
    Many thanks Cri2T, that works perfectly - much appreciated, although I didn't quite understand the last line - sorry ;-( How would I get their IP address, if not putting the code above into the form please ?
     
    Kezi, Jul 21, 2008 IP
  6. Cri2T

    Cri2T Peon

    Messages:
    104
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You would do something like this on the form-submit page:
    
    $ip = $_SERVER['REMOTE_ADDR']; //Put their IP in a variable named ip.
    
    PHP:
    Put that somewhere close to the top of the page (to make sure it gets their IP before you actually need to call the variable)

    Then wherever you want to display the IP or, whatever you want to do with it, you would simply use that variable.

    Lets say you want to display it on the page:
    
    <?php echo($ip); ?>
    
    PHP:

    If you don't know at-least basic PHP, forget about this post and go ahead and work with the sending through the form method above.
     
    Cri2T, Jul 21, 2008 IP
  7. Kezi

    Kezi Active Member

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #7
    Aah, I think I see what you mean, no, the purpose is not to view the ip address on the page, it's just for me to receive it contained in their emails from the form.

    Have I understood properly ?
     
    Kezi, Jul 21, 2008 IP
  8. Cri2T

    Cri2T Peon

    Messages:
    104
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Not exactly, which is fine. The form will work just fine;

    (once something is in a variable in PHP, you can do pretty much anything with it)

    If you want, you could PM me the mailing part and I could edit it to include the persons IP address and a timestamp (if you don't already have one) :D
     
    Cri2T, Jul 21, 2008 IP
  9. Kezi

    Kezi Active Member

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #9
    Many thanks Cri2T, the timestamp isn't needed, but I do get a lot of spam to that form, on the URL posted above - is it not as secure as possible from spammers ?

    Kezi.
     
    Kezi, Jul 21, 2008 IP