Strona 1 z 1

Komentarze - 2 skrypty - nie mam pojęcia jak to zrobić :(

PostNapisane: 27 marca 2007, o 22:51
przez arbgor
Na swojej stronce http://www.arbgor.prv.pl która jest napisana w HTMLu chciałbym umieścić księgę gości oraz dziale Fotki pod każdą fotką by można było dodać komentarz, (tzn odnośnik do stronki z komenatarzami i formularzem do dowania nowych).

Znalazłem takie dwa skrypty:
PIERWSZY:


<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=ISO-8859-2">
<title>Księga Gości - Dopisz Się</title>
</head>
<body background="bck.jpg">
<center><form action="dopisz.php" method=POST>
Miejsce na Twoją wypowiedź: <br><textarea name="wpis" rows=5 cols=30></textarea>
<br><br>Twój nick:<input name="nick">
<br><br>
<input type="submit" name="wyslij" value="Dopisz się">
</form>

<?php
ini_set ('displays_errors' , 1) ;
if (isset ($_POST['wyslij'])) {
if ( !empty ($_POST['wpis']) and !empty ($_POST['nick'])) {
if ($wp = fopen ('wpisy.txt' , 'ab')) {
if (ini_get ('magic_quotes_gpc')) {
$dane = stripslashes ($_POST['wpis']) ;
$podpis = stripslashes ($_POST['nick']) ;
} else {
$dane = $_POST['wpis'] ;
$podpis = $_POST['nick'] ;
}
flock ($wp, LOCK_EX) ;
fwrite ($wp, "$dane\r\n") ;
fwrite ($wp, "$podpis\r\n") ;
flock ($wp, LOCK_UN) ;
fclose($wp) ;
print ("Wpis został dodany! Dziękujemy!") ;
} else {
print ("Wpis nie został dodany z powodu błędu skryptu, spróbuj ponownie.") ;
}
} else {
print ("Wprowadź swój wpis i nick!") ;
}
}
?>
</center>
</body>
</html>


DRUGI:

<html>
<body>
<?
/*

annotate.php3

This is a module that can be placed on any php3 page to allow users to add
their comments. The comments are stored in a file in the current directory,
whose name is constructed by adding ".comment" to the calling page's name,
and merged into the calling page dynamically. (The calling page is not
modified.)

I wrote this because I wanted a simple way to add this functionality to my
pages without requiring that mySQL be available.

In the message input, blank lines are converted to paragraph tags. No other
conversions are applied. If you don't want your users to be able to input
html, uncomment the "strip_tags" line.

Note that the directory must be writable by the web server.

Put this module in some convenient location and then embed it in your pages
like so:

require("/some/full/path/annotate.php3");
or, relative to the docroot:
require($DOCUMENT_ROOT . "/relativepath/php3");

Steve Yelvington <[email protected]>

*/
if ($message)
{
/* uncomment the next two lines to strip out html from input */
/* $name = strip_tags($name); */
/* $message = strip_tags($message); */
$message = ereg_replace("\r\n\r\n", "\n<P>", $message);
$date = date("l, F j Y, h:i a");
$message = "<B>$name </B> -- $date<P> $message <BR><HR>";
$fp = fopen (basename($PHP_SELF) . ".comment", "a");
fwrite ($fp, $message);
fclose ($fp);
}
@readfile(basename(($PHP_SELF . ".comment")));
?>
<FORM method="post">
<b>Your name:</b><BR><INPUT name="name" type="text" size="55"><BR>
<b>Your comment:</b><BR><TEXTAREA name="message" rows=10 cols=55 wrap=virtual>
</TEXTAREA><BR>
<INPUT name="submit" type="submit" value="Post your comments">
</FORM>

</body>
</html>

Stronkę mam na serwerze PRV.PL (nie tylko alias lecz hosting) który obsługuje PHP ale nie MySQL.
Nie znam się całkowicie na PHP a chciałbym mieć coś takiego na mojej stronce, bez żadnych zewnętrznych stron które oferują darmowe Księgi itp.
Nie wiem właśnie co mam zrobić z takim skryptem...
1. trzeba będzie pewnie utworzyć plik tekstowy w którym będą zapisywane komentarze?
2. po "włożeniu" samego skryptu do strony HTML między znaczniki <body></body> oczywiście jak ją zapisać?? z rozszerzeniem *.html czy innym?
3. Najlepiej by było żeby nad formularzem po dodaniu komentarza pojawiały się wpisane komentarze.