PDA

View Full Version : page only seen by certain people



Jamesy
11-06-2007, 04:37 PM
is there a way so only certain IP adresses, or people can see a link to a webpage? if not wots the code for a password thing.

+rep!

Mario
11-06-2007, 04:39 PM
i'll also give +rep :)

Blob
11-06-2007, 04:50 PM
You could do this:



<?php
$password = $_GET["password"];

if( isset( $password ) )
{
if( $password == "yourpasswordhere" )
{
echo "stuff here you want only people to see";
} else {
echo "Wrong password!";
}
}
?>


To access it you would go to www.yoursite.com/yourpage.php?password=yourpasswordhere

Get it?

Mentor
11-06-2007, 04:50 PM
Urmm, yea, easly. Basicly u just want a backwards version of an IP blocker script (for ip method)


<?php

//Array of alloed ip's (continue as so.
$allow[0] = "000.000.000.001";
$allow[1] = "000.000.000.002";
$allow[2] = "000.000.000.003";

//set up start value
$alloweduser = false;

// Loop Threw All the Ips.
for($K = 0; $K<sizeof($allow); $K++)
{
//If an Ip matches the user ip set em as allowed.
if($allow[$K] == $_SERVER['REMOTE_ADDR']){
$alloweduser = true;
}
}

// stop page load if there not on allowed list
if($alloweduser == false){die("you cannot view this page.");}

?>
^^ place at top of protected page, just add to the $allow array to allow more ips to view.. just wrote it now but i think will work

Want to hide these adverts? Register an account for free!