Creating a custom browser redirection script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pup100
Forum Newbie
Posts: 2
Joined: Wed Jun 19, 2002 3:40 pm
Location: London

Creating a custom browser redirection script

Post by pup100 »

New to PHP new to programming. Have bought a brief introduction to the subject & have been fascinated & impressed by the possibilities & versatility of the code.

My problem.

Having been choughed by some early experiments in using getenv & preg_match functions to identify a browser, how would I be able to automatically redirect a browser to the corresponding browser page?

I have set out below my most recent attempt, which no doubt is most lamentable but if anyone could “hold my hand” on this one & explain basically where I’m going wrong I would most appreciate it.

<?

$agent = getenv("HTTP_USER_AGENT");

if (preg_match("/MSIE/i", "$agent")) {
header ("Location: = http://www.My IE6 site");
exit;
}

?>


Thank you very much for any assistance

JD
(London)
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

are you sure it's set in the enviroment?
Try instead $_SERVER['HTTP_USER_AGENT'] (or $HTTP_SERVER_VARS php.version < 4.1.0) and have a look at get_browser
Zmodem
Forum Commoner
Posts: 84
Joined: Thu Apr 18, 2002 3:59 pm

Post by Zmodem »

I don't believe there is an = sign in the header statement. Try removing it.

Also, make sure you aren't sending anything to the browser before you call header();
pup100
Forum Newbie
Posts: 2
Joined: Wed Jun 19, 2002 3:40 pm
Location: London

Thank you

Post by pup100 »

thank you very much for the input. I will try these options out.

Cheers chaps.

JD
Post Reply