WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Use HTTP_USER_AGENT for redirection to a page if the browser is Internet Explorer or another page if it is another browser.
Categories : PHP, Browsers Update Picture
Christophe BAN
Date : Feb 03rd 2000
Grade : 4 of 5 (graded 2 times)
Viewed : 7558
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Christophe BAN
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?php



/* I made this code for my school site because it put frames (with <IFRAME> tags that
Netscape doesn't accept). Feel free to use and modify the script.
I don't use ereg( "MSIE", $HTTP_USER_AGENT) function because IE lies about its name! */



$browser = $HTTP_USER_AGENT;

$a = strstr($browser , "MSIE");
$z = strlen($a);

/* z return a number >0 if MSIE is matched and 0 if not */

if ($z = 0 )
{$loc = "index2.htm";}
else { $loc = "index1.htm";}

/* change the url: index1 is for IE and index2 for other browsers */



?>

<html> <head>


<meta http-equiv=refresh content="1; URL=<? echo $loc; ?>">

</head> <body> </body> </html>




How to force the user to download a file instead of opening it up in an controlled environment within the browser (i.e. MS Word/Adobe Acrobat)
Categories : Browsers, PHP, HTTP
Most of the browsers, especially Internet Explorer, behave in different ways. Hence it become necessary to use Browser detection to fix the non standard behavior of the browser. This is a browser sniffer class that can be used for the above purpose.
Categories : PHP, PHP Classes, Browsers
Browser Detection, Redirection Type, MSIE, MOZILLA, Netscape Navigator, NS, $HTTP_USER_AGENT, HTTP_USER_AGENT
Categories : PHP, HTTP, Browsers, HTML and PHP
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
Automatic Browsers Detect
Categories : PHP, PHP Classes, Headers, Browsers
cpdf_add_annotation -- Adds annotation
Categories : PHP, PHP Functions, ClibPDF
Newbie Notes #5 - To double quote, or single quote, that is the question
Categories : PHP, Beginner Guides, Variables
Quote For the Day
Categories : PHP, Utilities, Filesystem
$REMOTE_HOST does not return a value.
Categories : PHP, Global Variables, HTTP
A simple class with some HTML output functions that would come in handy for consistent page layout etc.
Categories : PHP, PHP Classes, HTML and PHP, HTML, Navigation
News management class
Categories : PHP, PHP Classes, Beginner Guides
MIME records PHP Array
Categories : PHP, Misc
Checking for valid (or lack thereof) input.
Categories : PHP, Perl
recode -- Recode a string according to a recode request
Categories : PHP, PHP Functions, Recode
Generate HTML Calendar of a month of year
Categories : PHP, Calendar, PHP Classes
 John Walsh wrote : 213
Surely the above script will generate a redundant entry 
in the browsers history list  (you know, a `back` button 
problem)?

Wouldn`t it be better to run a script on the basis of the 
browser`s initial request, i.e. keep it all happening at 
the server end?

There`s a perl cgi solution along these lines at

http://www.wirewd.com/wpt/tool/redir.html

Anybody know how to write this sort of thing in php? 
(sorry, I`m not a coder - more of a paster!)
 
 Josh Tuttle wrote : 225
This script is a really good idea but it just doesn`t 
work...
 
 John Walsh wrote : 228
 .... oh yes it does (oh no it doesn`t) ...
Here`s an example of it working

http://www.nottingham.ac.uk/tsd/

You get a dhtml page for 4x`s and text only for the rest.

Obviously you wont be able to see the script, but it is 
the exact same thing as that avaliable from wirewd.com
 
 Ronny Vaardal wrote : 471
Just an idea.. Will something like this work? (I have no time to test at this moment)... :

&lt;?php 

$browser = $HTTP_USER_AGENT;  

$a = strstr($browser , "MSIE");  
$z = strlen($a);  

/*  z return a number &gt;0 if MSIE is matched and 0 if not  */   

if ($z = 0 ) 
{$loc = "ns.htm";} 
else { $loc = "ie.htm";} 

/*  change the url: index1 is for IE and index2 for other browsers  */   

header("location: $loc");

?&gt; 


This would remove the "back-button" problem wouldn`t it?
 
 Ronny Vaardal wrote :472
Sorry... I think will do it this way:

&lt;?

$browser = $HTTP_USER_AGENT;

    $a = strstr($browser , "MSIE");
    $z = strlen($a);

    if ($z = 0 ) {
        $location = "ns/";
        }
    else {
        $location = "ie/";
        }

    $mylocation = $SERVER_NAME.$REDIRECT_URL;
    $newlocation = $mylocation.$location;

    header("location: $newlocation");
?&gt;


This would work I guess... (have no chance to check it right now)