Results 1 to 10 of 24

Thread: Day 10 - Let's Eat Cookie - Become PHP Expert in 30 days

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2003
    Posts
    3,040

    Default

    Quote Originally Posted by stefin View Post
    http://php.flashwebhost.com/stefin/set_cookie.php

    Code:
    <?php
    
    
    if (isset($_COOKIE['flipkartCustomer'])) {
        echo $_COOKIE['flipkartCustomer'] . ',Welcome to flipkart, SPECIAL OFFER- 50% OFF ON ALL GAMES';
    exit;
    }
    
    
    if (isset($_POST['flipkartCustomer']) && strlen($_POST['flipkartCustomer']) > 5) {
       setcookie('flipkartCustomer', $_POST['flipkartCustomer'], time()+3600);
       echo 'COOKIE Set. Close the browser. Revisit this page, I will remember your name';
    } else {
    
    
    echo'
        Enter your name ?
        <form method="post" action="">
        <input type="text" name="flipkartCustomer">
        <button type="submit" name="whatever">Enter Name</button>
      ';
    }
    Thank you for the discount.
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

  2. #2
    Join Date
    Nov 2009
    Location
    kerala
    Posts
    19,076

    Default PHP setcookie and delete cookie

    http://php.flashwebhost.com/sibichan...set_cookie.php

    PHP Code:
    <?php

    if (isset($_COOKIE['memberName'])) {

    echo 
    'Hi ! 'strtoupper($_COOKIE['memberName']) .', Welcome to Group.<br>(<a href=delete_cookie.php>Click here to delete cookie</a>)';

    exit;

    }
    if (isset(
    $_POST['memberName']) && strlen($_POST['memberName']) > 3) {

        
    setcookie('memberName'$_POST['memberName'], time()+3600);

        echo 
    'Cookie Set. Close the browser. Revisit this page, I will remember your name <br>(<a href=delete_cookie.php>Click here to delete cookie</a>)';

    }else {
    echo 
    '    Enter your Name    <form method="post" action="">    <input type="text" name="memberName">    <button type="submit" name="whatever">Enter Group</button>    </form>

    '
    ;

    }

  3. #3
    Join Date
    Sep 2003
    Posts
    3,040

    Default

    Quote Originally Posted by sibichan1 View Post
    http://php.flashwebhost.com/sibichan...set_cookie.php

    PHP Code:
    <?php

    if (isset($_COOKIE['memberName'])) {

    echo 
    'Hi ! 'strtoupper($_COOKIE['memberName']) .', Welcome to Group.<br>(<a href=delete_cookie.php>Click here to delete cookie</a>)';

    exit;

    }
    if (isset(
    $_POST['memberName']) && strlen($_POST['memberName']) > 3) {

        
    setcookie('memberName'$_POST['memberName'], time()+3600);

        echo 
    'Cookie Set. Close the browser. Revisit this page, I will remember your name <br>(<a href=delete_cookie.php>Click here to delete cookie</a>)';

    }else {
    echo 
    '    Enter your Name    <form method="post" action="">    <input type="text" name="memberName">    <button type="submit" name="whatever">Enter Group</button>    </form>

    '
    ;

    }
    Good use of delete cookie.
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

Tags for this Thread

Bookmarks

Posting Permissions

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