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
hhs
Forum Newbie
Posts: 4 Joined: Thu Dec 08, 2011 5:19 pm
Contact:
Post
by hhs » Thu Dec 08, 2011 5:32 pm
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
twinedev
Forum Regular
Posts: 984 Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio
Post
by twinedev » Thu Dec 08, 2011 8:18 pm
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:
Post
by hhs » Fri Dec 09, 2011 7:13 am
helppppp meeee
it doesent work
i want redirect opera users to another page
twinedev
Forum Regular
Posts: 984 Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio
Post
by twinedev » Fri Dec 09, 2011 8:56 am
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:
Post
by hhs » Fri Dec 09, 2011 2:56 pm
Celauran
Moderator
Posts: 6427 Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada
Post
by Celauran » Fri Dec 09, 2011 3:05 pm
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:
Post
by hhs » Sat Dec 10, 2011 2:58 pm
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' ) ;
}
?>