Reputation: 591
What is the if condition for php to check if the page the user is viewing is identical as URL?
For example, here is a default URL: "example.com/my_name"
If the user is viewing "example.com/my_name"
, then the condition is met.
However, if the user is viewing "example.com/my_name&first_name"
then the condition is not met.
(I am not sure if I am explaining it right :P)
Thanks!
Upvotes: 0
Views: 49
Reputation: 99081
My solution is to use the SERVER variables, i.e.:
$currentLocation = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$base = $_SERVER['SERVER_NAME']."/my_name";
if($currentLocation != $base){
echo "LOCATION DENIED";
}else{
echo "LOCATION OK";
}
The above code compares the base location with the current user location;
'SERVER_NAME'
The name of the server host under which the current script is executing. If the script is running on a virtual host, this will be the value defined for that virtual host.
'REQUEST_URI'
The URI which was given in order to access this page; for instance, '/index.html'.
http://php.net/manual/en/reserved.variables.server.php
Upvotes: 2