that old header problem...
Posted: Fri Jun 11, 2010 9:22 am
sup folks, im having that old header error:
[text]Warning: Cannot modify header information - headers already sent by (output started at C:\set.php:7) in C:\set.php on line 31[/text]
but my code apparently has no problems, whitespaces, etc.
could someone take a look and see whats wrong? its just a code to test setting a cookie.
[text]Warning: Cannot modify header information - headers already sent by (output started at C:\set.php:7) in C:\set.php on line 31[/text]
but my code apparently has no problems, whitespaces, etc.
could someone take a look and see whats wrong? its just a code to test setting a cookie.
Code: Select all
<?php
echo "
<html>
<head>
<title>SET YOUR COOKIE!</title>
</head>
<body>";
if (isset($_COOKIE['usern']))
{
$usern=$_COOKIE['usern'];
echo "Username ".$usern."already set.";
}
else
{
echo "
Username:
<form method='post'>
<input type='text' name='name'></input><br />
<input type='submit' name='submit' value='Submit'></input>
</form>";
}
if(isset($_POST['submit']))
{
if(($_POST['name'])!="")
{
$name=$_POST['name'];
echo $name;
setcookie('usern', $name, time()+3600);
}
else
{
echo "<script language='JavaScript'>alert('You must type a name.');</script>";
}
}
echo "
</body>
</html>";
?>