I’m so sorry to come here for what has probably been asked before (I swear I did search the tutorials, but I don’t think I know the terminology enough to ask the right question), but I’ve been searching for days trying to find any hint on how to make the form action I need, and I figured a PHP help forum might be the best place. I’m willing to learn PHP from the ground up if I must, but I’m hoping someone can just help me create a code snippet that will get the job done.
What I’m trying to do is to create a HTML5-based webpage with a simple, single input field and form submit button that takes the line the visitor types and adds it, permanently, to the webpage itself. I know it’s a spam risk, so I plan on putting it behind a login. I’m trying to make a webpage that, at the bottom, has a section where visitors can add a line of text. (thereby reducing a significant workload to myself having to manually add every entry every person emails to me every week)
I know how to create the HTML side of forms, and how to link to a PHP file to process the input, but I do not know PHP much at all, and the problem I’m having is that all the PHP form processors and snippets I can find only submit the text someone enters as a mailto link to email it to me. That’s not what I want at all. Does anyone have a php form processor that will take the submitted text and add it to the webpage itself, permanently, so it remains as a public part of the page forever (sort of like a public comments section does - I can style it down to be more compact from there)? I was considering installing an entire php forum system and trying to edit it down to do what I want, but that seems like an extremely complex solution for such a simple little need, and I’m not sure how to take a system that makes threads and cut it back to what I need (which is not threaded and has no ability to add responses to posts). I just need one input field with a submit button, that adds one line of text to the webpage (publicly, permanently). Surely there is a way?
I found this:
[php] <?php
$myfile = fopen(“newfile.txt”, “w”) or die(“Unable to open file!”);
$txt = “John Doe\n”;
fwrite($myfile, $txt);
$txt = “Jane Doe\n”;
fwrite($myfile, $txt);
fclose($myfile);
?> [/php]
which seems like I’m onto something, but I need to find a way to incorporate this open/write process from the form input submission, along with (I think) an ID (probably inside a span or div tag), I think, so it appends each submission as a linear entry on the page and eliminates the possibility of overwrites.
Since I was thinking it is a lot like a public comments form, I’ve searched and searched for a code snippet, but all the “add a comments box to your website” links in google search results seem to be for services, not actually giving you the code to make this on your own. I don’t understand why this is such a secretive process, it should be simple enough, yet I can’t find any mention of how to create it. Can anyone help? I am willing to learn if this is something so complex that really learning PHP from the ground up is the only way.