Get IP Address Help [message #170709] |
Tue, 16 November 2010 03:25 |
Jim Higgins
Messages: 20 Registered: November 2010
Karma: 0
|
Junior Member |
|
|
PHP 5.2.13
I'm trying to capture a visitor's IP address in a web form (a ballot
for club office) and am coming up empty handed. Purpose is to head
off ballot box stuffing. All sorts of Googling keeps coming up with
the following...
<input type="hidden" name="ip"
value="<?php echo $_SERVER['REMOTE_ADDR'] ?>">
which just gives me the literal PHP script between the double quotes
instead of the voter's IP address.
Help please?
|
|
|
Re: Get IP Address Help [message #170710 is a reply to message #170709] |
Tue, 16 November 2010 03:51 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 11/15/2010 10:25 PM, Jim Higgins wrote:
>
> PHP 5.2.13
>
> I'm trying to capture a visitor's IP address in a web form (a ballot
> for club office) and am coming up empty handed. Purpose is to head
> off ballot box stuffing. All sorts of Googling keeps coming up with
> the following...
>
> <input type="hidden" name="ip"
> value="<?php echo $_SERVER['REMOTE_ADDR'] ?>">
>
> which just gives me the literal PHP script between the double quotes
> instead of the voter's IP address.
>
> Help please?
Is this on a page with a .php extension? Is your web server set up to
parse php files?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
|
Re: Get IP Address Help [message #170713 is a reply to message #170710] |
Tue, 16 November 2010 06:04 |
Jim Higgins
Messages: 20 Registered: November 2010
Karma: 0
|
Junior Member |
|
|
On Mon, 15 Nov 2010 22:51:23 -0500, Jerry Stuckle
<jstucklex(at)attglobal(dot)net> wrote:
> On 11/15/2010 10:25 PM, Jim Higgins wrote:
>>
>> PHP 5.2.13
>>
>> I'm trying to capture a visitor's IP address in a web form (a ballot
>> for club office) and am coming up empty handed. Purpose is to head
>> off ballot box stuffing. All sorts of Googling keeps coming up with
>> the following...
>>
>> <input type="hidden" name="ip"
>> value="<?php echo $_SERVER['REMOTE_ADDR'] ?>">
>>
>> which just gives me the literal PHP script between the double quotes
>> instead of the voter's IP address.
>>
>> Help please?
>
> Is this on a page with a .php extension? Is your web server set up to
> parse php files?
Oh crap! HTM extension. And I know better! Changed the extension,
works fine now. Thank you, Jerry!
I'm a small step or two above the novice level, but I've been using
PHP and MySQL for very simple tasks long enough that I knew something
was seriously strange when the above wouldn't work. Didn't think the
answer would be quite so embarrassing.
Thanks again.
|
|
|
Re: Get IP Address Help [message #170714 is a reply to message #170712] |
Tue, 16 November 2010 06:16 |
Michael Fesser
Messages: 215 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
.oO(richard)
> Wouldn't the $_Server stuff have to be assigned to a variable first, then
> echoed through the variable?
No. $_SERVER already is a variable.
Micha
|
|
|
Re: Get IP Address Help [message #170720 is a reply to message #170713] |
Tue, 16 November 2010 16:00 |
BootNic
Messages: 10 Registered: November 2010
Karma: 0
|
Junior Member |
|
|
On Tue, 16 Nov 2010 06:04:00 +0000
Jim Higgins <invalid(at)invalid(dot)invalid> wrote:
> On Mon, 15 Nov 2010 22:51:23 -0500, Jerry Stuckle
> <jstucklex(at)attglobal(dot)net> wrote:
>
>> On 11/15/2010 10:25 PM, Jim Higgins wrote:
[snip]
>>>
>>> <input type="hidden" name="ip" value="<?php echo
>>> $_SERVER['REMOTE_ADDR'] ?>">
>>>
>>> which just gives me the literal PHP script between the double
>>> quotes instead of the voter's IP address.
[snip]
>> Is this on a page with a .php extension? Is your web server set
>> up to parse php files?
>
> Oh crap! HTM extension. And I know better! Changed the
> extension, works fine now. Thank you, Jerry!
[snip]
Nice to have it sorted yes.
Is there some reason that the ip address would be necessary to
place in a hidden input? Open to anyone that may take the time to
look and possiblely edit the source.
Can it not be taken when the form is processed?
--
BootNic http://bootnic.bounceme.net Tue Nov 16, 2010 11:00 am
A conclusion is the place where you get tired of thinking.
*Arthur Bloch*
|
|
|
Re: Get IP Address Help [message #170721 is a reply to message #170720] |
Tue, 16 November 2010 18:58 |
Captain Paralytic
Messages: 204 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On Nov 16, 4:00 pm, BootNic <bootnic.bou...@gmail.com> wrote:
> Is there some reason that the ip address would be necessary to
> place in a hidden input? Open to anyone that may take the time to
> look and possiblely edit the source.
>
> Can it not be taken when the form is processed?
Whilst this is a better idea, there is not much point taking it anyway
since the ip address in
$_SERVER['REMOTE_ADDR'] is not unique to a visitor. Anyone sitting
behind the same NAT Router or Proxy (used by many business) will share
the same value.
|
|
|
Re: Get IP Address Help [message #170723 is a reply to message #170721] |
Tue, 16 November 2010 22:34 |
Jim Higgins
Messages: 20 Registered: November 2010
Karma: 0
|
Junior Member |
|
|
On Tue, 16 Nov 2010 10:58:26 -0800 (PST), Captain Paralytic
<paul_lautman(at)yahoo(dot)com> wrote:
> On Nov 16, 4:00 pm, BootNic <bootnic.bou...@gmail.com> wrote:
>> Is there some reason that the ip address would be necessary to
>> place in a hidden input? Open to anyone that may take the time to
>> look and possiblely edit the source.
>>
>> Can it not be taken when the form is processed?
Yes. I moved it to the form handler where it's all PHP and can't be
inspected.
> Whilst this is a better idea, there is not much point taking it anyway
> since the ip address in
> $_SERVER['REMOTE_ADDR'] is not unique to a visitor. Anyone sitting
> behind the same NAT Router or Proxy (used by many business) will share
> the same value.
True, but we'll be collecting other data that when combined with IP
will prevent irregularities in the voting.
|
|
|
|