PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Warning: Cannot add header information - headers already sent by (output started at /usr/local/psa/home/vhosts/abeta.anime-honor.com/httpdocs/function.php:168) in /usr/local/psa/home/vhosts/abeta.anime-honor.com/httpdocs/add_ffa.inc on line 12
what am i doing wrong? Ive never used cookies before.
It's because cookies are sent in HTTP "headers," and these headers are always sent before the HTML is. So you need to set your cookie before anything is outputted.
Or you could use "output buffering," to prevent anything from being outputted:
<?php ob_start(); ?> // Output buffer is enabled
<html>
<?php setcookie ("cookiename", "cookiedata"); ?>
</html>
<?php ob_end_flush(); ?> // This sends the HTML to the browser
Just make sure <?php ob_start(); ?> is at the very top of the PHP script.