Hello all. I’m taking a course learning php so my experience is very limited. Without posting the whole assignment, I’m having trouble redirecting. The code is supposed to check to see if the user is connecting from a 127.0.x.x or a 192.168.x.x ip.
•In the PHP portion of the solution03.php file, read in the contents of the REMOTE_ADDR environment variable, and save that string in a variable named $ipaddress.
•Construct an if statement which will test to see whether the $ipaddress contains either 127.0 or 192.168. If it does, re-direct the visitor to the greeting page you created for Assignment #1 (which should be named solution01.php).
•(NOTE: The simplest way to do this is to use the if clause to test for one of the two strings and an else if clause to test for the other. That is easier than using the OR logical operator . . .)
•If the address does not contain either of those strings, re-direct the visitor to a page named solution03_distant.html.
I’m now lost as to where im going wrong, trying to view the page, it says theres an error on line 20. skipping the blank HTML heres the php code.
[php]<?php
$ipaddress = getenv(“REMOTE_ADDR”);
if ($ipaddress =="127.0") {
header(“Location: solution01.php”);
}elseif ($ipaddress =="192.168") {
header(“Location: solution01.php”);
}else {
header(“Location: solution03_distant.html”);
}
?>[/php]
Any thoughts, pointers, tips, or pointing out the obvious would be greatly appreciated. Thank you.