Capturing The IP Address During A Form Submit

free web hosting
Free Web Hosting > Computers & Tech > Programming > Scripting > PHP

Capturing The IP Address During A Form Submit

ginginca
I was wondering how to add a (hidden) field to my submit form that will collect the IP address that someone is submitting from?

(I'd like to see if my spams are from the same source.)

Reply

bluefish
Well, you could add it to your form, but I would recommend just putting it on the page that processes the forms, as that would stop bots from altering the hidden fields.

CODE
$ip=@$REMOTE_ADDR;


To add in form:
CODE
<input type=hidden name=ip value="<?php echo @$REMOTE_ADDR; ?>">


Like I said before, programs (and even users with a bit of work) can alter hidden fields. So instead of using
CODE
$ip = $_POST['ip'];

or whatever, a better solution might be
CODE
$ip=@$REMOTE_ADDR;

without bothering with the field.

Reply

TavoxPeru
QUOTE(bluefish @ Jan 4 2007, 01:57 PM) *

Well, you could add it to your form, but I would recommend just putting it on the page that processes the forms, as that would stop bots from altering the hidden fields.

CODE
$ip=@$REMOTE_ADDR;


To add in form:
CODE
<input type=hidden name=ip value="<?php echo @$REMOTE_ADDR; ?>">


Like I said before, programs (and even users with a bit of work) can alter hidden fields. So instead of using
CODE
$ip = $_POST['ip'];

or whatever, a better solution might be
CODE
$ip=@$REMOTE_ADDR;

without bothering with the field.

If you can't get the correct value or no value use the $_SERVER variable instead, so, if its your case simply change it to:
CODE
$ip=@$_SERVER['REMOTE_ADDR'];

Best regards,

 

 

 


Reply

Hercco
For extra sneakiness you could also capture the IP with Javascript, have it sent vie the form and then check also the address from the HTTP request (i.e. the one you get from PHP. That way you could filter out machines using fake IPs.

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

Similar Topics

Keywords : Capturing Ip Address Submit

  1. Does Php Have This? - IP Address (7)
  2. Error On Submit Page - (10)
    I am writing a new submit page for one of my sites and am doing a few things to stretch my
    experience. I am getting an error (naturally.) Here is part pf the page where the error might be:
    CODE //Check to see if the web page called itself     if (strtoupper($action) == "CHECK") {
            //The web page called itself, so run the error checking code         //Declare a variable to
    hold the error messages     $error = '';      // variable names:    name, cat, sub_cat, url,
    date, status, email, other, area_code, city          $name = $_POST ;     $cat = $_P...
  3. Simple E-mail Validation - check for correct address and syntax (2)
    Hey , this tutorial will tell you a very simple way to check if email addresses entered are with the
    correct syntax. Hope this will help you eliminate jokers. So this script will... (check the
    characters, and check if there is a " someone somewhere.extension ". Ok, so firstly we create a
    function with all the invalid stuff in it:- CODE function CheckMail($email) { if (eregi("^ (
    ? )*@ ( ? )*\. {2,4}$", $email)) { return true; } else { return false; } } Now, to check an
    email you just run the variable with the email in it through the function as foll...



Looking for capturing, ip, address






*SIMILAR VIDEOS*
Searching Video's for capturing, ip, address
advertisement




Capturing The IP Address During A Form Submit