Showing a different page for a different browser?

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
hc2995
-


Joined: 07 Aug 2006
Posts: 644
Location: Maryland, USA

PostPosted: Sat Feb 17, 2007 1:29 am    Post subject: Showing a different page for a different browser? Reply with quote

Ok i am working with a friend (hes on here occasionally, pcmantinker) and we need to display a different home page for IE and FF. I have looked into the code and it think it would look like this:

Code:

<?php
$browser = get_browser(); //Gets the browser's name for later use

If ($browser == "Mozilla") { // If the browser is FireFox
Include(index.html);
} else if ($browser == "Internet Explorer") { //If the browser is IE
Include(index_IE.html);
} else { //If its not FF or IE
include(index.html);
}
?>


I haven't tested it yet, just wanted to see if anyone finds errors in the code before i use it.

NOTE: This is the first time iv used get_browser()

EDIT: I tried it on my site and i get something about browscap.ini, does anyone know what this is and where i get it?
_________________
Where have i been? School got heck-tick, had to move half way around the state, then back... and then i had to change jobs, so iv been away for a while :P
Back to top View user's profile Send private message AIM Address
roganty
-


Joined: 08 Jun 2004
Posts: 357
Location: Bristol, UK

PostPosted: Sat Feb 17, 2007 12:33 pm    Post subject: Re: Showing a different page for a different browser? Reply with quote

hc2995 wrote:
NOTE: This is the first time iv used get_browser()

EDIT: I tried it on my site and i get something about browscap.ini, does anyone know what this is and where i get it?


All the information that you require about get_brower() and browscap.ini can be found
on the php.net website

Looking at the outputted code on the php website, the code that you have used would not work, try using the links I have given above to help you.
_________________
Anthony R

Roganty
| Links-Links.co.uk
Back to top View user's profile Send private message Visit poster's website
abyssisthebest
-


Joined: 30 Jun 2005
Posts: 319
Location: Boston, UK

PostPosted: Sat Feb 17, 2007 12:36 pm    Post subject: Reply with quote

Hi,

I have never used the get_browser() function, but I have used the $_SERVER['HTTP_USER_AGENT'] which does the same job, then what you would have to do is perform a eregi on the contents of the vairable to see what browser they are using...

E.G
Code:
<?php
$browser = $_SERVER['HTTP_USER_AGENT'];
if (eregi("Firefox", $browser))
{
   // The user is using firefox
   print "You are using Firefox";
}elseif (eregi("MSIE", $browser))
{
   //The user is using IE
   print "You are using IE";
}else{
   // The user is using another browser
   print "You are not using firefox, or Internet Explorer";
}
?>


I have tested this code, and it works, then all you need to do to show the users a different page is use the header("Location: http://www.domain.com") or header("location: ./index_blah.php");

I hope this helps
Back to top View user's profile Send private message Send e-mail MSN Messenger
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Sat Feb 17, 2007 4:07 pm    Post subject: Re: Showing a different page for a different browser? Reply with quote

hc2995,

You can do that with the URL rewriting feature only (by adding a condition which tests HTTP_USER_AGENT).
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
hc2995
-


Joined: 07 Aug 2006
Posts: 644
Location: Maryland, USA

PostPosted: Sat Feb 17, 2007 7:01 pm    Post subject: Re: Showing a different page for a different browser? Reply with quote

aprelium wrote:
hc2995,

You can do that with the URL rewriting feature only (by adding a condition which tests HTTP_USER_AGENT).


Hummm, ill ask him if he know how to use url rewriting (its on his server, which is AWS :P) or if he can give me access to the control panel
_________________
Where have i been? School got heck-tick, had to move half way around the state, then back... and then i had to change jobs, so iv been away for a while :P
Back to top View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group