He probado con el código de esta manera, pero sigue sin funcionar:
Código:
<?php
header ('Content-type: text/html; charset=utf-8');
$saving = $_REQUEST['saving'];
if ($saving == 1) {
$data = $_POST['data'];
$file = "data.txt";
$fp = fopen($file, "wb") or die("Couldn't open $file for writing!");
fwrite($fp, $data) or die("Couldn't write values to file!");
fclose($fp);
echo "Saved to $file successfully!";
}
?>
<meta http-equiv="Content-type" value="text/html; charset=UTF-8" />
<form name="form1" method="post" action="form.php?saving=1">
<textarea name="data" cols="100" rows="10">
<?php
$file = "data.txt";
if (!empty($file)) {
$file = file_get_contents("$file");
echo stripslashes($file);
}
?>
</textarea>
<br>
<input type="submit" value="Save">
</form>
Y me imprime el siguiente error:
Warning: Cannot modify header information - headers already sent by (output started at.........................
¿Ideas?