FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Get IP Address Help
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Get IP Address Help [message #170709] Tue, 16 November 2010 03:25 Go to next message
Jim Higgins is currently offline  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 Go to previous messageGo to next message
Jerry Stuckle is currently offline  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 #170712 is a reply to message #170710] Tue, 16 November 2010 05:14 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
On Mon, 15 Nov 2010 22:51:23 -0500, Jerry Stuckle 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?

Wouldn't the $_Server stuff have to be assigned to a variable first, then
echoed through the variable?
Re: Get IP Address Help [message #170713 is a reply to message #170710] Tue, 16 November 2010 06:04 Go to previous messageGo to next message
Jim Higgins is currently offline  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 Go to previous messageGo to next message
Michael Fesser is currently offline  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 Go to previous messageGo to next message
BootNic is currently offline  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 Go to previous messageGo to next message
Captain Paralytic is currently offline  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 Go to previous messageGo to next message
Jim Higgins is currently offline  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.
Re: Get IP Address Help [message #170791 is a reply to message #170709] Fri, 26 November 2010 17:11 Go to previous message
Twayne is currently offline  Twayne
Messages: 135
Registered: September 2010
Karma: 0
Senior Member
In news:ocu3e6tdjs4rbm7pm43haa32hfdtv3d9vb(at)4ax(dot)com,
Jim Higgins <invalid(at)invalid(dot)invalid> typed:
> 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?

It's easy to get a visitor's IP address, but ... realize that this IP
address will NOT last.
If it's a dialup, EVERY time they exit/enter, they'll have a new IP.
If it's DSL, the IP changes on usually a set schedule with a few
exceptions. Most seem to get a new IP at least every 24 hours or less, plus
the user can easily kill and request a new address anytime he wants to.
I don't know what FIOS does; it's a different animal and so if IPV6.

Your IP CAN be changed even as you are using your client for access.

You really need to make yourself familiar with "the man ual" and other PHP
resources; then you wouldn't have had to ask here.
http://php.net/manual/en/reserved.variables.server.php

http://www.phpbuilder.com/board/showthread.php?t=10327697

http://www.phpf1.com/tutorial/get-ip-address.html

http://www.cyberciti.biz/faq/php-howto-read-ip-address-of-remote-computerbr owser/

Google only has 16 million results on a search, so ... learn how to use it
for what you need. These are all from the first page of displays.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How to do the String concatenation with PHP - running a little Parser based on cURL
Next Topic: setup of curl-multi: looping over a bunch of sites [how to adress the array]
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 04:22:49 GMT 2024

Total time taken to generate the page: 0.02864 seconds