/    Sign up×
Community /Pin to ProfileBookmark

Can someone PLEASE HELP me out?

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:

<?PHP
$js = $_GET[“js”];
if($js==0){
setcookie(“js”, 0, time()+60*60*24*30, ‘/’, ‘.foxvalleynews.com’);
echo (‘<html>
<title>Fox Valley Newspapers</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
</head>
<frameset cols=”134,*
” frameborder=”NO” border=”0″ framespacing=”0″ rows=”*“>
<frame name=”leftFrame” scrolling=”NO” noresize src=”index-2.html”>
<frame name=”mainFrame” src=”index-1.html”>
</frameset>
<noframes>
<body bgcolor=”#FFFFFF” text=”#000000″>
</body>
</noframes>
</html>’);
} else if($js==1) {
setcookie(“js”, 1, time()+60*
60*24*30, ‘/’, ‘.foxvalleynews.com’);
echo (‘<html>
<title>Fox Valley Newspapers</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
</head>
<frameset cols=”134,*” frameborder=”NO” border=”0″ framespacing=”0″ rows=”*“>
<frame name=”leftFrame” scrolling=”NO” noresize src=”index-2.html”>
<frame name=”mainFrame” src=”index-withJavaScript.html”>
</frameset>
<noframes>
<body bgcolor=”#FFFFFF” text=”#000000″>
</body>
</noframes>
</html>’);
} else {
echo (“<h1>Please click <a href=”jsEnabled.php”>here</a></h1>”);
}
echo $_
COOKIE[“js”]; // print cookie value
?>

Thanks

to post a comment
PHP

27 Comments(s)

Copy linkTweet thisAlerts:
@pyroJul 16.2003 — So, what exactly do you need?
Copy linkTweet thisAlerts:
@Tasmanian_DevilauthorJul 16.2003 — 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.

Thanks Pyro
Copy linkTweet thisAlerts:
@pyroJul 16.2003 — Do you have either one of them working?
Copy linkTweet thisAlerts:
@Tasmanian_DevilauthorJul 16.2003 — The above script is to check for javascript but it does not work

Thanks
Copy linkTweet thisAlerts:
@pyroJul 16.2003 — This returns 1 for each variable ($js and $cookies) if they are enabled:

[code=php]<?PHP
setcookie("cookies","yes",time() +"3600");
$js = 0;
$cookies = 0;
if (isset($_GET["js"])) {
$js = 1;
}
if (isset($_COOKIE["cookies"])) {
$cookies = 1;
}
echo $js."|".$cookies;
?>

<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>[/code]
Copy linkTweet thisAlerts:
@Tasmanian_DevilauthorJul 19.2003 — pyro~

I was wondering, how to set the php up so that if one or both are 0 then goes to a differnet page?

Thanks
Copy linkTweet thisAlerts:
@pyroJul 20.2003 — Try something along these lines:

[code=php]<?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 OR $js equals 0
header("Location:http://www.yourdomain.com/nojsorcookies.php");
}
?>[/code]
Copy linkTweet thisAlerts:
@Tasmanian_DevilauthorJul 20.2003 — 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?

Thanks
Copy linkTweet thisAlerts:
@pyroJul 20.2003 — I meant to replace the PHP part of my prior repley with that PHP. Like this:

[code=php]<?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 OR $js equals 0
header("Location:http://www.yourdomain.com/nojsorcookies.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>[/code]
Copy linkTweet thisAlerts:
@Tasmanian_DevilauthorJul 20.2003 — 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.

Thanks
Copy linkTweet thisAlerts:
@pyroJul 20.2003 — That's what you asked for above:

how to set the php up so that if one or both are 0 then goes to a differnet page?[/quote]Anyway, try this out:

[code=php]<?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");

}
?>[/code]
Copy linkTweet thisAlerts:
@Tasmanian_DevilauthorJul 20.2003 — Pyro~

Not sure what I am doing wrong so here is the [URL=http://216.104.190.167/4.html]page[/URL] to check out and tell me what the heck I am doing wrong. If you do not mind.

Thanks
Copy linkTweet thisAlerts:
@pyroJul 20.2003 — 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:

[code=php]<?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>[/code]
Copy linkTweet thisAlerts:
@Tasmanian_DevilauthorJul 22.2003 — Pyro~

What am I doing wrong again?

Here is the [URL=http://216.104.190.167/4.php]page.[/URL]

Thanks
Copy linkTweet thisAlerts:
@pyroJul 22.2003 — I get this error:

Parse error: parse error in /usr3/home/foxvalleynews.com/htdocs/4.php on line 12

What does line 12 look like?
Copy linkTweet thisAlerts:
@Tasmanian_DevilauthorJul 22.2003 — Pyro~

I am not sure I think it is one of the following lines:

if ($cookies == 0 && $js == 0) { #in english: if $cookies equals zero AND $js equals 0

header("Location:<a href="http://www.yourdomain.com/nojsorcookies.php" target="_blank">http://www.yourdomain.com/nojsorcookies.php</a>");

}

else { #if js and cookies are enabled

header("Location:<a href="http://www.yourdomain.com/enabled.php" target="_
blank">http://www.yourdomain.com/enabled.php</a>");

I have not changed the domains yet as you can see, was just wondering if it work.

Thanks
Copy linkTweet thisAlerts:
@pyroJul 22.2003 — Try the code in [URL=http://forums.webdeveloper.com/showthread.php?s=&postid=71704#post71704]this[/URL] post again. I think the forums did a bit of formating that might have messed it up...
Copy linkTweet thisAlerts:
@Tasmanian_DevilauthorJul 22.2003 — Pyro~

That one works great except, when the cookies only are enabled and the js is disabled, the user still goes to the enabled page rather than the disabled page.

Thanks
Copy linkTweet thisAlerts:
@pyroJul 22.2003 — Not for me... You sure you actually had it disabled?
Copy linkTweet thisAlerts:
@Tasmanian_DevilauthorJul 22.2003 — Pyro~

Well I might no have. Well one last thing, how do I put that into my index.html? I want to have the user w/cookies and/or js disable to go to a page, and w/them enable to go to a page that has frame. here is what I had before, but the php does not work.

<?PHP

$js = $_GET["js"];

if($js==0){

setcookie("js", 0, time()+60*60*24*30, '/', '.foxvalleynews.com');

echo ('<html>

<title>Fox Valley Newspapers</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<frameset cols="134,*
" frameborder="NO" border="0" framespacing="0" rows="*">

<frame name="leftFrame" scrolling="NO" noresize src="index-2.html">

<frame name="mainFrame" src="index-1.html">

</frameset>

<noframes>

<body bgcolor="#FFFFFF" text="#000000">

</body>

</noframes>

</html>');

} else if($js==1) {

setcookie("js", 1, time()+60*
60*24*30, '/', '.foxvalleynews.com');

echo ('<html>

<title>Fox Valley Newspapers</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<frameset cols="134,*" frameborder="NO" border="0" framespacing="0" rows="*">

<frame name="leftFrame" scrolling="NO" noresize src="index-2.html">

<frame name="mainFrame" src="index-withJavaScript.html">

</frameset>

<noframes>

<body bgcolor="#FFFFFF" text="#000000">

</body>

</noframes>

</html>');

} else {

echo ("<h1>Please click <a href="jsEnabled.php">here</a></h1>");

}

echo $_
COOKIE["js"]; // print cookie value

?>

can you help?

Thanks
Copy linkTweet thisAlerts:
@pyroJul 22.2003 — The code I posted above does just that... just change the values of the redirects, and insert that code on your index.php page... For PHP to work, it must have a .php extention.
Copy linkTweet thisAlerts:
@Tasmanian_DevilauthorJul 24.2003 — Pyro~

I was wondering with your php you gave me, why can I only bypass the disabled page if I have every thing enabled as well as type in the www.----.com? out of four ways how I should be able to type it only one lets me by.

Thanks
Copy linkTweet thisAlerts:
@pyroJul 24.2003 — You lost me on this part:

[i]Originally posted by Tasmanian Devil [/i]

[B]as well as type in the www.----.com? out of four ways how I should be able to type it only one lets me by.[/B][/QUOTE]
Copy linkTweet thisAlerts:
@Tasmanian_DevilauthorJul 24.2003 — Pyro~

Sorry about that. now it is a total ramdom thing when it blocks me out or not. before I could not get through but now after ten minutes, I can get through. any reason?

Thanks
Copy linkTweet thisAlerts:
@pyroJul 24.2003 — I've had problems setting the time() on cookies the way you did it ( time()+60*60*24*30 )

Try: time()+2592000
Copy linkTweet thisAlerts:
@Tasmanian_DevilauthorJul 25.2003 — Pyro~

Still having problems with the time issue.

Thanks
Copy linkTweet thisAlerts:
@pyroJul 25.2003 — Hmmm... don't really know what to tell you. Try looking around http://us2.php.net/manual/en/function.setcookie.php and playing with some of the cookie examples and see if they work for you.
×

Success!

Help @Tasmanian_Devil spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...