Reads in data from a form textbox & writes it to "testFile.txt" It then reads "testFile.txt" and displays the results
Code:
<html>
<head><title="PHP Test"></title></head>
<body>
<?php if ($_POST["submitData"] != "")
{
$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $_POST["submitData"]);
fclose($fh);
} ?>
<form action="test.php" method="post">
<input type="text" name="submitData"/>
<input type="submit"/>
</form>
Data read from file:
<?php $myFile = "testFile.txt" or die("Can't open file");
$fh = fopen($myFile, 'r');
$theData = fread($fh,filesize($myFile));
fclose($fh);
echo $theData; ?>
</body>
</html>