Results 1 to 10 of 24

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

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Feb 2005
    Location
    India
    Posts
    11,004

    Default

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

    PHP Code:
    <?php

    if (isset($_COOKIE['VisitorName'])) {
        echo 
    'Hi ' $_COOKIE['VisitorName'];
        exit;
    }

    if (isset(
    $_POST['VisitorName']) && strlen($_POST['VisitorName']) > 3) {
        
    setcookie('VisitorName'$_POST['VisitorName'], time() + (86400 7)); // Remember 1 week
        
    echo 'Cookie Set. Close the browser. Revisit this page, I will remember your name for 1 week';
    } else {

        echo 
    '
            What is your name ?
            <form method="post" action="">
            <input type="text" name="VisitorName">
            <button type="submit" name="Submit">Remember Me</button>
            </form>
        '
    ;
    }
    I am getting the following warning message

    Code:
    Warning: Cannot modify header information - headers already sent by (output started at /home/fwhphp/public_html/melbin/set_cookie.php:1) in /home/fwhphp/public_html/melbin/set_cookie.php on line 9
    Why ??
    Last edited by melbin; 05-21-2014 at 01:30 PM. Reason: changed to camelCase
    VIDEO WORLD : LATEST HOLLYWOOD || BOLLYWOOD || SOUTH INDIAN VIDEOS || TRAILERS

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
  •