Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2004
    Location
    Chicago, IL, USA
    Posts
    139

    contact form - how can I receive senders ip address?

    Below is a simple contact form I am using on my site.
    A lot of spam is being sent through it, and i'd like to know the ip addresses of the people / bots submitting the spam so i can ban them through my servers firewall.

    What do I add to the php to have it email me the senders ip address?

    Thanks in advance


    PHP Code:
    <?php

        
    if ($_POST && session_id() == $_POST['sid'])

        {

            
    $name    $_POST['name'];

            
    $email   $_POST['txtEmail'];

            
    $aim     $_POST['aim'];

            
    $phone   $_POST['phone'];

            
    $inquiry $_POST['Inquiry'];

            
    $message $_POST['message'];

            

            switch (
    $inquiry)

            {

                case 
    'pricing-sales'$inquiry "Pricing/Sales"; break;

                case 
    'wdesign'$inquiry "Design Services"; break;

                case 
    'wupport'$inquiry "Support"; break;

                case 
    'gquestion'$inquiry "General Question"; break;

            }

            
            
    // Email header info
            
    $headers .= "MIME-Version: 1.0\n";
            
    $headers .= "Content-type: text/plain; charset=utf-8\n";
            
    $headers .= "X-Priority: 3\n";
            
    $headers .= "X-MSMail-Priority: Low\n";
            
    $headers .= "From: \"" $name "\" <" $email ">\n";

            
    $text 

    "Someone has filled out a form to contact you.



    Name: " 
    $name "

    E-Mail Address: " 
    $email "

    Inquiry: " 
    $inquiry "

    Message: " 
    $message "



    . ($aim "AIM: " $aim "AIM was not supplied.") . "

    . ($phone "Phone: " $phone "Phone was not supplied.") . "

    Thanks.

    -Server"
    ;

            

            
    $success mail('*****@*****, 'Contact Message from *****', $text, $headers);
            
            $msg = ($success ? '
    Message was successfully sentThanks.' : 'Failed to send messagePlease try again later.');

         }
    ?>

  2. #2
    Join Date
    Jul 2004
    Location
    Chicago, IL, USA
    Posts
    139
    posted in wrong forum. Please move. Sorry.

    *edit*
    Thank you.
    Last edited by WAbizTony; 11-14-2006 at 08:16 PM.

  3. #3
    Join Date
    Oct 2006
    Posts
    44
    You could use the '$_SERVER["REMOTE_ADDR"]' variable. $_SERVER is another one of those superglobal variables, gives you lots of info on the server and connection.
    Andrew
    Spry VPS Hosting cPanel VPS, Plesk VPS, Webmin VPS, Shared, Domain Registration, Dedicated and Colo
    VPSLink Cheap VPS accounts CentOS, Fedora 4/5/6, RHEL, Gentoo, Debian, Ubuntu -- Dapper/Edgy, Slackware, OpenSUSE, LAMP + Ruby pre-installed available

Posting Permissions

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