Zoldkabatos Zoldkabatos - 1 year ago 133
PHP Question

How to create comment box in PHP without database?

I'm a noob trying to get some functionalities done on a website. Unfortunately, I have very little authorization, so I would like to create a comment box as simply as possible without the use of databases or jQuery, JavaScript.

I did a lot of searches and I believe the easiest way is to create a log-like HTML with a comment form, to which the PHP script would append the entered text. This is what I've managed to fabricate so far:

$file = "updates.html";
$fh = fopen($file, 'a');
$file = "updates.html";
$fh = fopen($file, 'a');
$comment = echo $_POST["update"] \n";
fwrite($fh, $comment);

The updates.html file has a comment box of which action points at a php file with the content above. Of course, it doesn't work, there is a parsing error, but I have no idea how to use the variable there (if that's the cause of the problem). I just can't figure out how to do it... Do you have any suggestions? Thanks!

Answer Source

don't know what you would like to do ....

  if(isset($_POST['update'])) {
     // if a request update exists
     $file = "updates.html";
     file_put_contents($file, $_POST['update']."\n",FILE_APPEND);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download