WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
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 Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
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
Submit Site
Forex Trading Online forex trading platform

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 : 2 of 5 (graded 1 times)
Viewed : 3894
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 
 

<?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
Retrieve text from table and email to your e- address in pipe delimited format.
Categories : PHP, MySQL
Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs.
Categories : Databases, PHP, MySQL, Complete Programs
A PHP function to encrypt and decrypt a number or string or a combination of the two.
Categories : PHP, Encryption, Security
Using $PHP_AUTH_USER and $PHP_AUTH_PW to authenticate.
Categories : Authentication, PHP
file class , uploade file , download file already uploaded on another website
Categories : PHP, PHP Classes, Filesystem, Web Services
Authorize.net AIM Interface Class v1.0.0
Categories : PHP, PHP Classes, Ecommerce, Payment Gateways
Cut your MySQL Connections to 1 line of code
Categories : PHP, Beginner Guides, Databases, MySQL
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
recode -- Recode a string according to a recode request
Categories : PHP, PHP Functions, Recode
PhpIBadmin - Web interface to Interbase RBDMS , this is a port of phpMyadmin
Categories : Databases, InterBase, PHP
Math operations on big numbers
Categories : PHP, Math.
 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)