How to redirect opera users?

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
hhs
Forum Newbie
Posts: 4
Joined: Thu Dec 08, 2011 5:19 pm
Contact:

How to redirect opera users?

Post by hhs »

hi all
How to redirect opera users?

i used this :

Code: Select all

if(preg_match('/MSIE/i',$u_agent) || preg_match('/Opera/i',$u_agent)) 
{ 
    header("Location: http://www.example/getfirefox.php");
} 
but it doesent work
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: How to redirect opera users?

Post by twinedev »

After any header("Location: .... ); you need an exit; so that the script stops running, otherwise they will still get all the output.
hhs
Forum Newbie
Posts: 4
Joined: Thu Dec 08, 2011 5:19 pm
Contact:

Re: How to redirect opera users?

Post by hhs »

helppppp meeee

it doesent work

i want redirect opera users to another page
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: How to redirect opera users?

Post by twinedev »

what is in $u_agent ? (not what you think it should be, what is the ACTUAL value)
hhs
Forum Newbie
Posts: 4
Joined: Thu Dec 08, 2011 5:19 pm
Contact:

Re: How to redirect opera users?

Post by hhs »

User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How to redirect opera users?

Post by Celauran »

You haven't answered twinedev's question. Also, I recommend reading the comments as to why doing this is a bad idea.
hhs
Forum Newbie
Posts: 4
Joined: Thu Dec 08, 2011 5:19 pm
Contact:

Re: How to redirect opera users?

Post by hhs »

hi
i found it
thank you ...

Code: Select all

<?php
$opera = stripos($_SERVER['HTTP_USER_AGENT'],"opera");
if ($opera=="true")
{
header( 'Location: http://www.toprank.ir/opera.php' ) ;
}
?>
Post Reply