I've integrated some of the older code with the newer code and have come up with this so far.
[Link]
http://yabadabadoo.blackapplehost.com/_AAA/TEST.php
PHP Code:
<html>
<head>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<textarea name="msg"></textarea>
<input type="submit" value="submit">
</form>
<?php
if (isset($_POST['msg'])){
//process message if submitted
if (file_exists("filecount.txt")){
//find out if there is a file count file
$filename = file_get_contents("filecount.txt");
//if so, use the stored number as the filename
} else {
//if not,
$filename = 1;
//set the filename to "1"
$fCount = fopen("filecount.txt", "w");
//then create the file count file
fwrite($fCount, "2");
//set its contents to "2", which will be the next filename
fclose($fCount);
//and close it
}
$input = $_POST['msg'];
if (!file_exists("write/$filename.txt")){
//if the filename is not already in use,
$fp = fopen("write/$filename.txt", "w");
fwrite($fp, $input).' ';
fclose($fp);
//write the submitted message to a file using the file name
$fInc = fopen("filecount.txt", "w");
//then, open the file count file
fwrite($fInc, (++$filename));
//add one to the value and rewrite it (now it's ready for the next submission)
fclose($fInc);
//and close it
}
function directory($result) {
/* This file shows the last 10 files posted to write directory */
$filename= "filecount.txt" ;
// Store file name to $filename
$fd = fopen ($filename , "r") or die ("Can't open $filename") ;
// Opens file and read's it's contents
$fstring = fread ($fd , filesize ($filename)) ;
// Stores file contents to $fstring
$fstring_two = $fstring-1;
//This stops a blank div displaying at top of page
$loop=$fstring-11;
//Set's a value of $fstring - 11 to $loop and only display's the last 10 entries
for ($i = $fstring_two; ; --$i) {
if ($i <= $loop) {
break;
} elseif ($i <= 0){
break;
}
echo "<div style='border: 1px #6D7B8D solid;'>";
// Writes Html
include('write/'.$i.'.txt');
// Includes txt files from write folder
echo "</div><br>";
// Writes Html
}
fclose($fd) ;
// Closes filecount.txt
}
echo '<b>Comments submitted so far:</b>';
echo directory($result);
}
?>
</body>
</html>
Bookmarks