Hello All,
I am trying to set my cookie via a function. However, I am not getting any luck.
Here is my reqs:
1) At every page refresh,see if there is a function to set the cookie already in the code. if there is add to it and publis it as "Current request count is" increase old one by one.
2) At refresh, if there is no cookie set, set one and initialised at 0 and increase it by 1.
Below is mu code, however it is given error - Warning: Cannot modify header information - headers already sent by (output started at /home/tayo/public_html/pagereq.php:16) in /home/tayo/public_html/pagereq.php on line 19
Current request count is :
+++++++++++++++++++++++ Below is code+++++++++++++++++++
I am trying to set my cookie via a function. However, I am not getting any luck.
Here is my reqs:
1) At every page refresh,see if there is a function to set the cookie already in the code. if there is add to it and publis it as "Current request count is" increase old one by one.
2) At refresh, if there is no cookie set, set one and initialised at 0 and increase it by 1.
Below is mu code, however it is given error - Warning: Cannot modify header information - headers already sent by (output started at /home/tayo/public_html/pagereq.php:16) in /home/tayo/public_html/pagereq.php on line 19
Current request count is :
+++++++++++++++++++++++ Below is code+++++++++++++++++++
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title> Activity 8.1 </title>
<style type="text/css" media="screen">.number {font-weight: bold;} </style>
</head>
<body>
<form action="taxcalc.php" method="post">
<h1> </h1>
</form>
<?php
$count = 0;
setcookie(pagereq, $value, time()+30,',',0);
//Function set_pagereq
function set_pagereq($value){
if (isset($pagereq)){
return $count++;
}
else{
return $count;
}
}
//Call Functions
$count=set_pagereq($value);
//print result
print "<p><div>
Current request count is : <span class=\"text\">$count</span></p></div>"
?>
</body>
</html>