need some help with code

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

Post Reply
dem9
Forum Newbie
Posts: 2
Joined: Tue Jan 13, 2009 3:26 am

need some help with code

Post by dem9 »

Hi i'm actually trying to modify a script which i downloaded, this is used to detect ie6, and give an error message if so. Here's the script

Code: Select all

<?php
// IE6 string from user_agent
$ie6 = "MSIE 6.0";
// detect browser
$browser = $_SERVER['HTTP_USER_AGENT'];
// yank the version from the string
$browser = substr("$browser", 25, 8);
// html for error
$error = "Text to display on Error";
// if IE6 set the $alert 
if($browser == $ie6){ $alert = TRUE; }
?>
What i was trying to do is to exit() the website if alert is true. Sorry, this might be simple as hell but i'm not a programmer (more the designer type)... would appreciate some help! thanks
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: need some help with code

Post by papa »

if($browser == $ie6) {
header("Location: http://google.com");
}
dem9
Forum Newbie
Posts: 2
Joined: Tue Jan 13, 2009 3:26 am

Re: need some help with code

Post by dem9 »

papa wrote:if($browser == $ie6) {
header("Location: http://google.com");
}
where exactly do i need to place this? Following the aforementioned script?
thanks
User avatar
blue-printf
Forum Newbie
Posts: 12
Joined: Mon Jan 12, 2009 9:27 am

Re: need some help with code

Post by blue-printf »

Code: Select all

 
// if IE6 set the $alert
if($browser == $ie6){ $alert = TRUE; }
 ?>
 
should be:

Code: Select all

 
// if IE6 set the $alert
if($browser == $ie6){ exit('sorry we are anti IE. were not going tp show you this awsome page '); }
 ?>
 
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: need some help with code

Post by papa »

Instead of: if($browser == $ie6){ $alert = TRUE; }

If you want redirect use header location otherwise use code above. :)
jthayne
Forum Newbie
Posts: 5
Joined: Fri Jan 09, 2009 10:51 am

Re: need some help with code

Post by jthayne »

dem9 wrote:
papa wrote:if($browser == $ie6) {
header("Location: http://google.com");
}
where exactly do i need to place this? Following the aforementioned script?
thanks
Yes. Post it after the above script, but make sure it is before anything is output onto the screen or the header() function will not work.
Post Reply