I am trying to make a text file storage system for my website.
Here is what I have so far.
I have gotten some parts to work, but am getting many more errors after making a few changes I thought would help.
I am trying to accomplish this task without changing pages or url.
<!DOCTYPE HTML>
<html>
<body>
<?php
if (isset($_POST)){
//Save File
$file = fopen($_POST['filename'] & ".txt","r+");
$text = $_POST["textdata"];
file_put_contents($file, $text);
fclose($file);
//Open File
$file = fopen($_POST['filename'] & ".txt", "r") or exit("Unable to open file.");
while(!feof($file)){
echo fgets($file). "<br />";
}
fclose($file);
}
echo '
<form name="savefile" method="post" action="' . $_SERVER['PHP_SELF'] . '">
File Name: <input type="text" name="filename" value=""><br/>
<textarea rows="20" cols="100" name="textdata"></textarea><br/>
<input type="submit" name="submit" value="Save Text to Server">
</form>
<br/><hr style="width: 100%; height: 4px;"><br/>
<form name="openfile" method="post" action="' . $_SERVER['PHP_SELF'] . '">
Open File: <input type="text" name="filename" value="">
<input type="submit" name="submit" value="Submit File Request">
</form>';
?>
</body>
<html>
If the only way is to have it redirect to a php page, then send it back, that is fine, but I have no clue how to do that, (even though its probably A LOT simpler)
Thanks for any help or advice you can provide me!
-Jake