I have the following code I have thrown together for a sort of live document per say in php, and html. It worked yesterday, but for some strange reason today It decided not to work. It was meant to save a file to server(.txt) and also display that file. here is my code:
<html>
<body>
<form name="savefile" method="post" action="">
<input type="hidden" name="filename" value="code"><br/>
<textarea rows="16" cols="100" name="textdata">
<?php
$text = file_get_contents('user.txt');
echo $text;
?>
</textarea><br/>
<input type="submit" name="submitsave" value="Save">
</form>
File Contents:<br/>
<?php
if (isset($_POST)){
if ($_POST['submitsave'] == "Save" && !empty($_POST['filename'])) {
if(!file_exists($_POST['filename'] . ".txt")){
$file = tmpfile();
}
$file = fopen($_POST['filename'] . ".txt","a+");
while(!feof($file)){
$old = $old . fgets($file). "<br />";
}
$text = $_POST["textdata"];
file_put_contents($_POST['filename'] . ".txt", $old . $text);
fclose($file);
}
?>
</body>
</html>
this is a php file btw the php in the textarea works, but the php that saves the text to the serverside is broken. this is my error: Parse error: syntax error, unexpected end of file in /homepages/31/d585123241/htdocs/test/red.php on line 27