I am trying to make it so the content is only for my IP address, and someone elses. I tried:
<?php
$ip = $_SERVER['REMOTE_ADDR'];
if ($ip = "FirstIp" && $ip="SecondIp") {
echo "Protect Content";
} else {
echo "You do not have permission to look at this. Your IP has been recorded. $ip";
$fileofips="list.txt";
$ip = "$_SERVER[REMOTE_ADDR]";
$file=fopen($fileofips, 'a');
fwrite($f, $_SERVER[REMOTE_ADDR]);
fclose($f);
}
?>
And it won't even capture intruding IPs. Please tune up the code ;P
if ($ip = "FirstIp" && $ip="SecondIp") {
A single equals sign is an assignment, not a comparison. Also, you probably meant ||; $ip can't be two things at once.
if($ip === "FirstIP" || $ip === "SecondIP") {
Also, you probably want newlines between your IPs in the file, so add a \n. Also also, putting a variable in double quotes like this:
$ip = "$_SERVER[REMOTE_ADDR]";
is pointless. Use the variable.
Your if statement is overwriting the $ip variable because you're using a single =; Change it to ==, and also the && to an || (one IP can't be two at the same time):
if ($ip == "FirstIp" || $ip == "SecondIp") {
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With