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 ??
Bookmarks