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?
Comment form, which posts comments on the website
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
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.
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.
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
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.