Page 1 of 1

need some help with code

Posted: Tue Jan 13, 2009 3:37 am
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

Re: need some help with code

Posted: Tue Jan 13, 2009 3:53 am
by papa
if($browser == $ie6) {
header("Location: http://google.com");
}

Re: need some help with code

Posted: Tue Jan 13, 2009 8:06 am
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

Re: need some help with code

Posted: Tue Jan 13, 2009 8:26 am
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 '); }
 ?>
 

Re: need some help with code

Posted: Tue Jan 13, 2009 9:07 am
by papa
Instead of: if($browser == $ie6){ $alert = TRUE; }

If you want redirect use header location otherwise use code above. :)

Re: need some help with code

Posted: Tue Jan 13, 2009 9:26 am
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.