Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Getting an IP for a form

    OK, I'm still a little new to PHP, but hopefully this is an easy one.

    I know how to do a basic e-mail form, using the mail("[my address]", "[subject line]", $message, $mailheaders) tag. Basically right now I'm trying to do a web poll. I know I could just use a poll like mypoll.net, but I'd like to know how to do this on my own.

    Is it possible to obtain the IP address of the voter, and if so, can I spoof the "From" and "Reply To" address as something like, somewebuser@IPaddress ?

    Any help would be appreciated. Thanks

  • #2
    Regular Coder
    Join Date
    May 2003
    Location
    34° 54' N 82° 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, there is a way, but I don't understand your question completely. For starters to echo the ip address
    PHP Code:
    <?php
    $theip 
    $_SERVER['REMOTE_ADDR'];
    echo 
    $theip;
    ?>
    That will echo the users IP Adress....
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #3
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the reply. Basically, what I want to do is have the IP address come to me in the e-mail result that comes from the form. I don't want respondents to be required to enter their e-mail addresses, however.

    In the form I'm using radio buttons; the value is "shows". I want the value name in the text of the e-mail. To add the IP to the text of the message, do I simply need to echo the IP, ie

    PHP Code:
    <?php $theip $_SERVER['REMOTE_ADDR'];

    $message="$_POST[shows]\n$_POST[theip];

    mail("
    mail@freerock1.com", "Shows Poll", $message); 

    ?>
    Also, since I don't necessarily need the sender's e-mail address, is it sufficient to just leave off the $mailheaders tags?

    Thanks again.

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    PHP Code:
    <?php 

    $theip 
    $_SERVER['REMOTE_ADDR'];

    $message $_POST['shows'] . "\n" $theip;

    mail("mail@freerock1.com""Shows Poll"$message); 

    ?>

  • #5
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Awesome. It works great.

    Thanks so much; you've both been very helpful.


  •  

    Posting Permissions

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