Jump to content

Need comments section for my photography site


kamranki

Recommended Posts

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!

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.