Page 1 of 1
Comment form, which posts comments on the website
Posted: Fri Nov 10, 2006 5:47 am
by Nylen
I'm trying to create a form with which people can post their comments on my website.
What I tried to do was create the layout in html 'post' the information to a PHP file, write the data to the end of a txt file (each info in new line), and then make the script read the file and print it.
Is this supposed to work?
If not then what are the alternatives?
Posted: Fri Nov 10, 2006 12:10 pm
by John Cartwright
It could work, yea..
I would preferably use a database to store the comments.
Posted: Sat Nov 11, 2006 2:35 pm
by califdon
I agree with Jcart, if this is a real application. I would go further and say that there are many cool scripts you can download for good looking 'guest book' functions, which this sounds like.
If you are trying to learn PHP and using this as an exercise, then Good For You! That's a great way to learn. If you haven't yet gotten around to learning database handling, then do it as you proposed. Otherwise, a database solution offers many advantages, including: ease of maintenance (such as deleting unwanted entries), ability to search or even display in different sequence, etc.
Posted: Sat Nov 11, 2006 5:51 pm
by Ambush Commander
Sometimes databases aren't available. If that's the case, check out
serialize() which prevents a lot of pitfalls in text files. If you get a lot of data this method won't scale, though.
Posted: Mon Nov 13, 2006 9:39 am
by Nylen
Thank you for the help, I'll keep doing it this way then. I am learning PHP now, and my website is a good excuse for that. (I already know C and C++, so basically it's just the high number of external functions that gets me confused occasionally.)