Jump to content

Recommended Posts

There is a predefined variable which stores the users IP address. $_SERVER['REMOTE_ADDR'] is the variable you want to use in order to retrieve the users IP Address.

Note dont rely on this as users IP addresses can change frequently and can be easily changed.
Link to comment
https://forums.phpfreaks.com/topic/13762-getting-ip-from-form/#findComment-53466
Share on other sites

a) post some actual code, not some file to download. 
b) you don't really need to pass the ip address [i]through[/i] your form, since it is a variable automatically created whenever a script is called. [b]wildteen88[/b] already told you that variable's name: $_SERVER['REMOTE_ADDR']

but if you insist on passing it through your form, you would pass it with a hidden field, something like this:

<input type='hidden' name='ipaddress' value='<?php echo $_SERVER['REMOTE_ADDR']; ?>'>

and then you could access it with $_POST just like any of your other variables (assuming you used the POST method).... or you could you know, just use $_SERVER['REMOTE_ADDR'] in the called script, as i just mentioned.

c) I slightly disagree with [b]wildteen88[/b] on IP reliability.  I will agree that in theory it is not advisable to rely soley on someone's ip/tcp level info because one's ip address could potentially change every http request, but in reality,  it does not.  And I will agree that someone could easily access your page via a different ip address intentionally.  why do you want to track the user's ip? is it for security reasons? to verify they are who they are?  as measures to prevent cracking attempt? 
Link to comment
https://forums.phpfreaks.com/topic/13762-getting-ip-from-form/#findComment-53841
Share on other sites

what part of "post some code, not some file to download" do you not understand? Neither I nor anybody else is here to download and sort through whatever amount of files you happen to have.

the example I gave you is more than ample information for you to sort through your own code.
Link to comment
https://forums.phpfreaks.com/topic/13762-getting-ip-from-form/#findComment-53852
Share on other sites

[quote author=Crayon Violent link=topic=99550.msg392497#msg392497 date=1152192719]
what part of "post some code, not some file to download" do you not understand? Neither I nor anybody else is here to download and sort through whatever amount of files you happen to have.

the example I gave you is more than ample information for you to sort through your own code.
[/quote]

Crayon Violent is right. You have already been told how to add it to the form. Now you need to post the mail script so that we may help you in adding it to the mail sent.

Also, if it is a simple form to mail then you should realy have no need for the users ip. It is not being posted to a database. So what other possible uses could there be?
Link to comment
https://forums.phpfreaks.com/topic/13762-getting-ip-from-form/#findComment-53879
Share on other sites

okay do you really think you need to post your entire code or just the relavent part. that's my point. nobody wants to read 40,000 lines of code for one simple thing. you already know what your code is supposed to do and where things already are, right? for example, you already know where in your code your form is, right? you already know where in your code the other variables are checked/inserted into your email right? adding the ip address to that list is as simple as adding that server variable to the list.  nobody should have to go through 40k lines of code for that.
Link to comment
https://forums.phpfreaks.com/topic/13762-getting-ip-from-form/#findComment-53937
Share on other sites

okay this obviously isn't your script that you made, seeing as how you don't seem to know anything about it.  this forum is not for altering 3rd party scripts to fit your needs.  i suggest you go ask whoever made your script. surely they must have their own forum.
Link to comment
https://forums.phpfreaks.com/topic/13762-getting-ip-from-form/#findComment-53942
Share on other sites

i already did help you. i told you what variable to use that holds the user's ip address, and how to use it.  and now, instead of bothering to try doing it yourself, you are wanting me (or someone else) to sort through fourty thousand lines of code to do it for you. that's not how it works around here. If you take my explaining all this to you as "bashing" then so be it.
Link to comment
https://forums.phpfreaks.com/topic/13762-getting-ip-from-form/#findComment-53948
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.