kamranki Posted April 15, 2010 Share Posted April 15, 2010 Hello all, It's been while since I have written something here! One more thing; my knowledge about PHP is almost zero. Though I can understand syntax somewhat if explained. OK, I have my own photography site (http://kamranki.com:1300/images/photography/index.html) here. I want visitors to be able to leave their comments on photos page (something like comments on blog articles). My webserver setup is as follows: - Windows XP Professional SP3 - Abyss Web Server - PHP 5.2 for Windows Since port 80 is blocked by my ISP, I have to resort to using port 1300. Photo thumbnails link to separate HTML files: index01.html index02.html index03.html index04.html . . . and so on Since I'm looking for a simple setup, I don't mind having comments stored in a text file (I think that setting up a database could complicate things so not really interested in going that way). The text file could be a common text file for all photos (with sections dividing comments for each photo) or a separate text file for each photo. Something like: index01.html >> index01.txt index02.html >> index02.txt index03.html >> index03.txt index04.html >> index04.txt . . . and so on Managing comments from a separate console or panel is not really a priority as I can always edit the text file(s) by hand. I could look into that later. Any pinpointers would be really appreciated. Thanks a bunch! Quote Link to comment Share on other sites More sharing options...
morocco-iceberg Posted April 15, 2010 Share Posted April 15, 2010 Google reading and writing to files. Quote Link to comment Share on other sites More sharing options...
andrewgauger Posted April 15, 2010 Share Posted April 15, 2010 Doesn't explain what he is doing, but you are going to essentially use fwrite to append comments to the individual files. http://php.net/manual/en/function.fwrite.php[/code] so you can do something like: <form method="postcomment.php" action="post"> <input type="input" name="name"> <textarea name="message"> <input type="hidden" name="page" value="index01"> <input type="submit"> </form> postcomment.php $name=$_POST["name"]; $message=$_POST["message"]; $page=$_POST["page"]; $fp=fopen("comments/".$name.".txt",'a'); if(fwrite($fp,"<p>Name: $name <br>Comment: $message </p>")) echo "Thank you for your comment"; This is by no means complete, but I hope it is enough info to get you started. Quote Link to comment Share on other sites More sharing options...
kamranki Posted April 16, 2010 Author Share Posted April 16, 2010 Thanks Andrew. I'll give it a try once I get back home (working & living in different cities). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.