Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2009
    Location
    India
    Posts
    11
    Thanks
    3
    Thanked 0 Times in 0 Posts

    How do I automatically open URL based on IF condition being met ?

    In continuation to

    Php Cookies Help
    ( special thanks to abduraooft )

    How do I automatically open URL based on IF condition being met ?

    Code:
    <?php
    if(isset($_COOKIE['lastVisit'])){
    $link = "c.html";
    }
    else{
    $inTwoMonths = 60 * 60 * 24 * 60 + time();
    setcookie('lastVisit', date("G:i - m/d/y"), $inTwoMonths);
    $link = "b.html";
    }
    ?>
    <html>
    <head></head>
    <body>
    <?php
    echo "<a href=\"$link\">Link</a>";
    ?>
    </body>
    </html>
    when i added
    Code:
    echo "<meta http-equiv="refresh" content="1;url=http://www.tycheit.com/c.html" /> ";
    in the if section...i am getting an error
    Last edited by gudipudi; 05-09-2009 at 01:22 PM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,853
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    PHP Code:
    <?php
    if(isset($_COOKIE['lastVisit'])){
    $link "c.html";
    }
    else{
    $inTwoMonths 60 60 24 60 time();
    setcookie('lastVisit'date("G:i - m/d/y"), $inTwoMonths);
    $link "b.html";
    }
    header($link); 
    ?>
    Or
    PHP Code:
    <?php
    if(isset($_COOKIE['lastVisit'])){
    $link "c.html";
    }
    else{
    $inTwoMonths 60 60 24 60 time();
    setcookie('lastVisit'date("G:i - m/d/y"), $inTwoMonths);
    $link "b.html";
    }
    ?>
    <html>
    <head>
    <?php
    echo "<meta http-equiv=\"refresh\" content=\"1;url=$link\" /> ";
    ?>
    </head>
    <body>
    <?php
    echo "<a href=\"$link\">Link</a>";
    ?>
    </body>
    </html>
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    gudipudi (05-09-2009)

  • #3
    New Coder
    Join Date
    May 2009
    Location
    India
    Posts
    11
    Thanks
    3
    Thanked 0 Times in 0 Posts
    awsome ......its working


  •  

    Posting Permissions

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