View previous topic :: View next topic |
Author |
Message |
hc2995 -
Joined: 07 Aug 2006 Posts: 644 Location: Maryland, USA
|
Posted: Sat Feb 17, 2007 1:29 am Post subject: Showing a different page for a different browser? |
|
|
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 |
|
|
roganty -
Joined: 08 Jun 2004 Posts: 357 Location: Bristol, UK
|
Posted: Sat Feb 17, 2007 12:33 pm Post subject: Re: Showing a different page for a different browser? |
|
|
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 |
|
|
abyssisthebest -
Joined: 30 Jun 2005 Posts: 319 Location: Boston, UK
|
Posted: Sat Feb 17, 2007 12:36 pm Post subject: |
|
|
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 |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Sat Feb 17, 2007 4:07 pm Post subject: Re: Showing a different page for a different browser? |
|
|
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 |
|
|
hc2995 -
Joined: 07 Aug 2006 Posts: 644 Location: Maryland, USA
|
Posted: Sat Feb 17, 2007 7:01 pm Post subject: Re: Showing a different page for a different browser? |
|
|
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 |
|
|
|