Zymic Forums

Webmaster resources

Zymic IRC Server

Chat in real time at irc.zymic.com - Learn More

Welcome

Welcome to the Zymic webmaster forums. Our forums are here to provide people the free ability to discuss a range of websites related topics such as design, development coding and marketing.

In order to post you will need to register for a zymic account or if you already have one simply login by using the form on the left.

left Zymic Webmaster ForumsWeb Design & DevelopmentServer Side ScriptingPHP right
  Reply to this topic Start new topic
left right
Project-Paradox
post Sep 24 2007, 07:16 PM
Post #1


Newbie
*

Group: Members
Posts: 17
Joined: 24-September 07
From: U.K
Member No.: 519



To define someone's IP We have to use the PHP REMOTE_ADDR Superglobal like this,
CODE
<?php $ip=$_SERVER['REMOTE_ADDR']  ?>


But if we want to tell someone's ip we have to do this;

CODE
<b>IP Address= <?php $ip ?></b>


If you just want to have the full thing in PHP we will use this,

CODE
<?php $ip=$_SERVER['REMOTE_ADDR'];
echo "<b>IP Address= $ip</b>";  ?>

Live Priview
Have Fun, P.S Is there a tutorial section? o.O
Go to the top of the page 
 
  + Quote Post
Adam
post Sep 24 2007, 07:19 PM
Post #2


Cool guy
***

Group: Moderators
Posts: 193
Joined: 27-May 07
From: N.Ireland
Member No.: 10



Amazing, just amazing.
Thanks.
Go to the top of the page 
 
  + Quote Post
Alex
post Sep 24 2007, 07:21 PM
Post #3


zIRC Network Admin
*******

Group: Administrators
Posts: 660
Joined: 10-March 07
From: Swindon, Wilts, UK
Member No.: 6



You should use $_SERVER['REMOTE_ADDR'] not $REMOTE_ADDR.
$_SERVER['REMOTE_ADDR'] is part of a superglobal, not a function.

http://uk2.php.net/manual/en/reserved.vari...ariables.server <-- better resource than this tutorial.
Go to the top of the page 
 
  + Quote Post
Project-Paradox
post Sep 24 2007, 07:22 PM
Post #4


Newbie
*

Group: Members
Posts: 17
Joined: 24-September 07
From: U.K
Member No.: 519



QUOTE(Alex @ Sep 24 2007, 07:21 PM) *
You should use $_SERVER['REMOTE_ADDR'] not $REMOTE_ADDR.
$_SERVER['REMOTE_ADDR'] is part of a superglobal, not a function.

http://uk2.php.net/manual/en/reserved.vari...ariables.server <-- better resource than this tutorial.

I'll Change it to the superglobal, and i don't use php.net that often,
Go to the top of the page 
 
  + Quote Post
SP_
post Sep 24 2007, 07:23 PM
Post #5


Newbie
*

Group: Members
Posts: 14
Joined: 23-September 07
From: Fredericksburg, VA
Member No.: 495



This blew my mind. Incredible.
Go to the top of the page 
 
  + Quote Post
MrTouz
post Sep 24 2007, 10:21 PM
Post #6


Outrageously Uber Ninja
*******

Group: Members
Posts: 1,196
Joined: 19-September 07
Member No.: 234



im impressed... really, powerfull in 2 lines of code tongue.gif
Go to the top of the page 
 
  + Quote Post
Zytran
post Sep 26 2007, 11:14 PM
Post #7


Newbie
*

Group: Members
Posts: 26
Joined: 19-September 07
Member No.: 60



http://www.php.net/getenv
Go to the top of the page 
 
  + Quote Post
Enom
post Sep 29 2007, 01:36 PM
Post #8


Member
**

Group: Members
Posts: 49
Joined: 28-September 07
Member No.: 627



You could just have used:
CODE
<?php echo $_SERVER['REMOTE_ADDR']; ?>


To display user's IP even with proxy:
CODE
<?php
$ip="";
$ip_proxy="";
if (getenv(HTTP_X_FORWARDED_FOR))
{
   if (getenv(HTTP_CLIENT_IP))
      $ip=getenv(HTTP_CLIENT_IP);
   else
   {
      $ip=getenv(HTTP_X_FORWARDED_FOR);
      $ip_proxy=getenv(REMOTE_ADDR);
   }
}
else
   $ip=getenv(REMOTE_ADDR);
echo $ip;
?>


Alex - removed shorttags, portability is a concern in public forum posts.
Go to the top of the page 
 
  + Quote Post
Mark
post Sep 29 2007, 07:28 PM
Post #9


Administrator
***

Group: Root Admin
Posts: 168
Joined: 30-January 07
Member No.: 1



QUOTE(Project-Paradox @ Sep 24 2007, 02:22 PM) *
i don't use php.net that often,

I suggest you start using it more. It's probably the best resource for writing scripts/programs in PHP.
Go to the top of the page 
 
  + Quote Post
 Reply to this topic Start new topic
left right
0 Members:
left right
 


Lo-Fi Version Time is now: 17th May 2012 - 12:38 AM