Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with URL matching

Status
Not open for further replies.

benrob82

Programmer
Jul 28, 2005
116
GB
Hi i'm trying to match these to URL's and if they match they need to direct the user to the login page

Code:
<?php

extract($_COOKIE);

#echo "databaseuser = $databaseuser <BR>";
#echo $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$uri = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];

$myurl1 = "test.url.net/other_pages/events.php";

if (((!$databaseuser) && ($uri == $myurl1)))
{
	header("Location: [URL unfurl="true"]http://test.url.net/other_pages/notloggedin.php");[/URL]
}
?>

can anyone see a reason why this wouldn't work?

thanks
 
thanks for the reply,

I've tried this also and it does return the same results but for some reason won't recognise that they are the same.

any ideas this is killing me??
 
I would break the test into two so you can echo some debug info:
Code:
if ($uri == $myurl1) echo '$uri == $myurl1 evaluates true';
else echo '$uri != $myurl1 evaluates false';
echo "\r\n";
if (!$databaseuser) echo '!$databaseuser evaluates true';
else echo '!$databaseuser evaluates false';
That will narrow down the part of the test that is not working as expected for you.

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
hi thanks for this it showed that the $uri != $myurl1 evaluates false

which I cant understand as the URL's shown look exactly the same
 
$uri != $myurl1 evaluates false

this means that they are "loosely" the same - which i guess is what you wanted as you say they look the same. If it evaluated true then the two strings would not be loosely the same. it would be better to use a tight positive evaluation of ($uri === $myurl1) in my opinion (and test for true, of course).

i think the problem is in your declaration of $databaseuser. what do you use this variable for and where does it get set? would it be better to test for isset or empty rather than a boolean result?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top