I'm trying to build a PHP/CMS thingy and it's all going great. But I just can't figure out how to make the simple line returns the user types into the text field show up once the text has been saved and included in the actual page. Is this something that I do on the "PHP Include" end or on the "save" end in the doc with the form in it???
Here's the code if anyone feels very generous and could add the right bit in the right place to make this happen! Thanks.
<?php
$saving = $_REQUEST['saving'];
if ($saving == 1) {
$data = $_POST['data'];
$file = "text_files/a1txt.txt";
$fp = fopen($file, "w") 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!";
}
?>
</p>
<form name="form1" method="post" action="a1txt.php?saving=1">
<textarea name="data" cols="70" rows="10">
<?php
$file = "text_files/a1txt.txt";
if (!empty($file)) {
$file = file_get_contents("$file");
echo $file;
}
?>
</textarea>
<br>
<input type="submit" value="Save">
</form>
Here's the code if anyone feels very generous and could add the right bit in the right place to make this happen! Thanks.
<?php
$saving = $_REQUEST['saving'];
if ($saving == 1) {
$data = $_POST['data'];
$file = "text_files/a1txt.txt";
$fp = fopen($file, "w") 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!";
}
?>
</p>
<form name="form1" method="post" action="a1txt.php?saving=1">
<textarea name="data" cols="70" rows="10">
<?php
$file = "text_files/a1txt.txt";
if (!empty($file)) {
$file = file_get_contents("$file");
echo $file;
}
?>
</textarea>
<br>
<input type="submit" value="Save">
</form>