View Full Version : Comments
04-30-2006, 09:52 PM
Ok here is what I would like to do...
Have a form on a page that allows a person to enter a name, and a comment. Then what they post will show up at the bottom of the page...any ideas?
05-01-2006, 10:14 AM
You could do it with mySQL, saving the comment and the persons name, as well as perhaps an id and a timestamp.
05-01-2006, 06:46 PM
I'd like to ask antother comments question...
I have a form where the user chooses the topic that he/she wants to comment on with a pulldown menu. like this....
If the user types in a comment about oranges, it will be written to a text file called 2.txt. Instead of having premade empty text files for each topic, can I use PHP to see if there is the appropriate txt file in the directory and write to it, and if it doesn't exist, can it generate an empty txt file with the appropriate name (1.txt, 2.txt, 3.txt)?
A book I'm reading hints at this but doesn't explain. Any ideas?
05-02-2006, 02:43 PM
can I use PHP to see if there is the appropriate txt file in the directory and write to it, and if it doesn't exist, can it generate an empty txt file with the appropriate name (1.txt, 2.txt, 3.txt)?
Yep! If you open a text file in mode "a" (append), it will place the pointer at the end of the file in write mode; if the file doesn't exist, it will create it.
$outputFile = fopen($appropriateTextFile, "a");
05-02-2006, 02:51 PM
Here is a basic grafitti script
Personally I would go the database method. It will make things alot simpler and tidier in the future.
05-02-2006, 03:32 PM
The database sounds like a good way to go. I'll have to read up on that though. I'm new to PHP but I can see the possibilities there.
Fumigator, would your solution only add to a preexisting file? I want to know if there is a script or function in PHP that would say "generate a file called whatever.txt and place the comments in it." Doesn't the appending mode only add to an already existing file?
Thanks for your suggestions!
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.