the following code, is to check to see if javascript is enabled, and if not, it goes to a page without frames. And if the javascript is enabled, it goes to a a page with frames. As well I would like the script to check for cookies enabled. So what I am really looking for is, a php to first search for cookies enabled and then javascript enabled, if only one or none of them are enabled, I want the user to be sent to one page, if both are enabled, then the the user is sent to a page that is set up for both and has frames.
The code that follows does not do the javascript part of the check:
Pyro~
I am looking for a php to do the following: 1) check for cookies enabled. 2) check for javscript enabled. and if only one or none of the are enabled, to send the user to a certain page. And if both of them are enabled, to send the user to a certain page with frames.
<html>
<head>
<script type="text/javascript">
if (!window.location.search.substr(1)) {
window.location.href = "test.php?js=yes"; //set test.php to the name of this page...
}
</script>
</head>
<body>
</body>
</html>
Pyro~
I am greatful of your help, but not sure if to combined the two php's you gave me into one or what you meant by your last reply. Can you explain a little better?
Pyro~
your php somewhat works, when just cookies are disabled, it still allows me to the page where they need to be enabled. And also do I need to do something when both are disabled, it just comes up a blank page, rahter than the page that should come up.
Well, let's start with the fact that it is a PHP page, and you gave it a .html extention. Try .php. Also, you forgot the JS part. Here is the whole thing:
PHP Code:
<?PHP
setcookie("cookies","yes",time() +"3600");
$js = 0;
$cookies = 0;
if (isset($_GET["js"])) {
$js = 1;
}
if (isset($_COOKIE["cookies"])) {
$cookies = 1;
}
if ($cookies == 0 && $js == 0) { #in english: if $cookies equals zero AND $js equals 0
header("Location:http://www.yourdomain.com/nojsorcookies.php");
}
else { #if js and cookies are enabled
header("Location:http://www.yourdomain.com/enabled.php");
}
?>
<html>
<head>
<script type="text/javascript">
if (!window.location.search.substr(1)) {
window.location.href = "test.php?js=yes"; //set test.php to the name of this page...
}
</script>
</head>
<body>
</body>
</html>
Bookmarks