Jump to content
xisto Community
ginginca

Capturing The IP Address During A Form Submit

Recommended Posts

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.)

Share this post


Link to post
Share on other sites

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.

$ip=@$REMOTE_ADDR;

To add in form:
<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
$ip = $_POST['ip'];
or whatever, a better solution might be
$ip=@$REMOTE_ADDR;
without bothering with the field.

Share this post


Link to post
Share on other sites

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.

$ip=@$REMOTE_ADDR;

To add in form:
<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
$ip = $_POST['ip'];
or whatever, a better solution might be
$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:
$ip=@$_SERVER['REMOTE_ADDR'];
Best regards,

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Replying to bluefishOk I did alot of looking around and what I found to capture the ip address in a form as to create the html form into a php like it is mentioned above.But I added this to the form and made into a php----------->--in the form.Php then I mde the capture page in php like formsent.Php---------------------------------->$msg .="IP Address: $ip=@[$REMOTE_ADDR]and";I found nothing else on the internet that explaines it this much detail... Enjoy ;-)-reply by Tony

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.