Important alert: (current site time 7/15/2013 10:49:37 AM EDT)
 

VB icon

[ IP Address Access... ]

Email
Submitted on: 5/8/2004 6:40:20 PM
By: JamesJD  
Level: Beginner
User Rating: By 10 Users
Compatibility: PHP 3.0, PHP 4.0
Views: 22038
author picture
(About the author)
 
     This is a very simple code to allow the user on the page if they have the IP Address which is required. Best for broadband users... Please, leave your comments and votes... :)
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: [ IP Address Access... ]
// Description:This is a very simple code to allow the user on the page if they have the IP Address which is required. Best for broadband users... Please, leave your comments and votes... :)
// By: JamesJD
//
// Inputs:All you need to do is change the IP Address to your own... Enjoy :)
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=1361&lngWId=8//for details.//**************************************

<?php
	$IP = $REMOTE_ADDR;
	If ($IP == "82.40.82.111")
	{
	Print("Yay!");
	} else {
	Print("Boo!");
	}
?>


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

5/23/2004 5:53:10 AMangry_armadillo

you can use $_SERVER['REMOTE_ADDR']

which saves you a line of code ;)
(If this comment was disrespectful, please report it.)

 
5/23/2004 7:43:57 AMJamesJD

My code isn't supposed to tell you the IP Address. It just cross-references the admins IP Address. I.E. '82.40.82.111'...
(If this comment was disrespectful, please report it.)

 
5/30/2004 6:10:00 AMVigge Hallberg

Using register globals is bad practice, i advise you to use $_SERVER['REMOTE_ADDR'] instead...
(If this comment was disrespectful, please report it.)

 
8/27/2004 4:26:12 PM

ya, good code. sometimes i need ;) thx
(If this comment was disrespectful, please report it.)

 
10/16/2004 6:43:56 PM

What if the page was requested by a proxy server?
here's your answer:
$ip = $HTTP_SERVER_VARS['REMOTE_ADDR'];
if($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']) $ip = $HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'];
(If this comment was disrespectful, please report it.)

 
12/9/2004 8:04:45 AM

i really enjoing to use your code, its a valuable for me
(If this comment was disrespectful, please report it.)

 
5/27/2005 5:33:50 AMSalmanPaji



[ UNDER 100 BYTES ] AND ILL GO WITH THE OTHER METHOD THAT OTHERS HAS SUGGESTED :)
(If this comment was disrespectful, please report it.)

 
7/28/2005 9:13:00 PMSecman

i dont think so
(If this comment was disrespectful, please report it.)

 
8/9/2006 12:25:03 PMStaš R.

Excelent!
(If this comment was disrespectful, please report it.)

 
12/8/2006 5:07:28 PMaj

hey sir could u help me

(If this comment was disrespectful, please report it.)

 
12/17/2006 7:35:44 AMJoaquin Marcher

and... it's for????????????

if i have dinamical IP?

PD: you never tabule your code?
(If this comment was disrespectful, please report it.)

 
1/26/2007 2:58:18 AMDicky Kurniawan

somewhat useful..
(If this comment was disrespectful, please report it.)

 
4/15/2007 8:44:59 AMBrendon Boshell

You could put:



you should use echo instead of print because it's faster (doesn't return a value)

but good, nonetheless
(If this comment was disrespectful, please report it.)

 
1/7/2008 6:41:49 AMvenu.k

It's Good
(If this comment was disrespectful, please report it.)

 
1/23/2008 2:19:05 PMAric Holland

not bad. but it would be much cooler if you could read an array of ip addresses from a text file. - good code nevertheless :)
(If this comment was disrespectful, please report it.)

 
3/3/2008 4:22:23 PMonur

good
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.