I'm still learning PHP and just starting to get to grips with it.

$url = $_SERVER['REQUEST_URI'];
$user = $_SERVER['HTTP_USER_AGENT'];

if ($url == "/example.php" && $user == "HelloWorld")
	echo "";
else 
	Header("Location: http://www.google.co.uk");

Basically what I'm trying to achieve is when the useragent is "HelloWorld" and the URL is [root]/example.php the user stays on the page ... otherwise they're redirected to google...

But, I'm being redirected to Google both when my useragent IS HelloWorld, and even when the URL ISN'T /example.php ...

All help is hugely appreciated!
Brownie. :)

I think your problemen is The url.
Try echoing it, you Will see THE problem then.

You are comparing à part of THE url with == this is only possible if you use THE complete url.

Excuse my iPad typing...lol

I think your problemen is The url.
Try echoing it, you Will see THE problem then.

You are comparing à part of THE url with == this is only possible if you use THE complete url.

Excuse my iPad typing...lol

Hey man thanks for the reply!

The reason why I did the "/example.php" is because when I echoed it, that' what it said:

$url = $_SERVER['REQUEST_URL'];

echo $url;

I'll have a go at sticking in the full URL - the problem I've got is that I'm using WAMP on my localhost ... so perhaps that could be the problem?

yes this is possible, try it on a live server

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.