View Full Version : header already modified [resolved]

11-04-2007, 06:40 PM
Hy guys.
I was writing simple comment script for a friend, and now i'm stuck with page refresh. This is the full script

<!--Some random HTML code-->

<?php echo file_get_contents("komentari.txt"); ?>

<form action="" method="post">
<li><input type="text" name="nadimak"></li>
<li><textarea name="text"></textarea></li>
<li><input type="submit" value="komentiraj"></li>
if (isset($_POST['nadimak'])) {

if ($_POST['nadimak'] == '' || $_POST['text'] == '') {
echo "Ispunite oba polja";
else {
$nadimak = htmlspecialchars($_POST['nadimak']);
$text = htmlspecialchars($_POST['text']);

$tekst .= "<h3>".stripslashes($nadimak)." kaže:</h3>\n<p class=\"komentar\">".stripslashes($text)."</p>\n";

upis ($tekst);

function upis ($tekst) {
$file = "komentari.txt";
$file = fopen ($file, 'a+');
fputs ($file, $tekst);
fclose ($file);
#where did i set those headers?!
header("Location: index.php");


Error code:

Warning: Cannot modify header information - headers already sent by (output started at D:\xampp\htdocs\WORK\jasamza\index.php:6) in D:\xampp\htdocs\WORK\jasamza\index.php on line 70

How can i refresh this page so that i get rid of POST variable?!

Ok, another one i resolved right after posting. Just looked at the error, and figured out that if i put f-ion above the <doctype> headers will work, and that's true... mod's you can either delete or lock, or do nothing at all :D