I'm only starting to learn code with the help of youtube and other sites, and I've run tino a problem. Here's my code:
<form action="" method="post" id="c">
<label> Name: <br><input type="text" name="name" size="36"></label><br></br>
<label> Message: <br><textarea cols="35" rows="5" name="mes"></textarea></label><br></br>
<input type="submit" name="submit" value="Submit" class="texty" >
</form>
<?php
$post = $_POST["post"];
$name = $_POST["name"];
$text = $_POST["mes"];
if ($post) {
#WRITE DOWN COMMENTS#
$write = fopen("c.txt", "a+");
fwrite($write, "<u><b> $name</b></u><br>$text<br></br>");
fclose($write);
#DISPLAY COMMENTS#
$read = fopen("c.txt", "r+t");
echo "All comments:<br>";
while (!feof($read)) { #this line does the error#
echo fread($read, 1024);
}
fclose($read);
}
else{
#DISPLAY COMMENTS#
$read = fopen("c.txt", "r+t");
echo "All comments:<br>";
while (!feof($read)) {
echo fread($read, 1024);
}
fclose($read);
}
?>
So I have 2 files, the one where you input your comment and post it, and another .txt file where what you have typed is pasted and then echoed back on the page. I think something may be wrong with the permission of the files, because if i put it to "r" only, then it doesn't give me the error, but then it doesn't save what I try to post... Thank you for reading and replying.