www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 28

Thread: Can someone PLEASE HELP me out?

  1. #1
    Join Date
    Mar 2003
    Posts
    432

    Angry 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

  2. #2
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    So, what exactly do you need?

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  3. #3
    Join Date
    Mar 2003
    Posts
    432
    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

  4. #4
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Do you have either one of them working?

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  5. #5
    Join Date
    Mar 2003
    Posts
    432
    The above script is to check for javascript but it does not work
    Thanks

  6. #6
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    This returns 1 for each variable ($js and $cookies) if they are enabled:

    PHP Code:
    <?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>

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  7. #7
    Join Date
    Mar 2003
    Posts
    432
    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

  8. #8
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Try something along these lines:

    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 == || $js == 0) { #in english: if $cookies equals zero OR $js equals 0
        
    header("Location:http://www.yourdomain.com/nojsorcookies.php");
    }
    ?>

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  9. #9
    Join Date
    Mar 2003
    Posts
    432
    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

  10. #10
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    I meant to replace the PHP part of my prior repley with that PHP. Like this:

    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 == || $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>

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  11. #11
    Join Date
    Mar 2003
    Posts
    432
    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

  12. #12
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    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?
    Anyway, try this out:

    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 == && $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");

    }
    ?>

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  13. #13
    Join Date
    Mar 2003
    Posts
    432
    Pyro~
    Not sure what I am doing wrong so here is the page to check out and tell me what the heck I am doing wrong. If you do not mind.

    Thanks

  14. #14
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    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 == && $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>

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  15. #15
    Join Date
    Mar 2003
    Posts
    432
    Pyro~
    What am I doing wrong again?
    Here is the page.

    Thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles