ciao raga ho realizzato questo piccolo guestbook ma nn va ! come posso fare ?! grazie
posto il codice :
<?
//lettura e scrittura su file
$datafile = "files/data-txt";
if(isset($_POST['submit'])){
$name = $_POST['name'];
$comments = $_POST['comments'];
$new_content = "$name::$comments\n";
$fp = fopen($datafile, "a");
$fw = fwrite($fp, $new_content);
$fc = fclose($fp);
}
?>
<html>
<body bgcolor="#FFFFFF" text="#FFFFFF"">
GUESTBOOK
<form name="form1" method="post"
action="<? echo $_SERVER['PHP_SELF']; ?>">
<table width="30%" border="0" cellspacing="0" height="50">
<tr>
<td width="31%"><span class="Stile1">Nome:</span></td>
<td width="69%"><input type="text" name="name"></td>
</tr>
<tr>
<td width="31%"><span class="Stile1">Commenti:</span></td>
<td width="69%"><textarea name="comments"
rows="3"></textarea></td>
</tr>
</table>
<input type ="submit" name="submit" value="Invia Commento">
<input type="reset" name="Reset" value="Reimposta">
</form>
<hr>
<?php
//lettura di dati da un file e creazione di un ciclo per la loro visualizzazione
if (file_exists($datafile)) {
$read_data = file($datafile);
$num_comments = count($read_data);
for($c=0;$c<$num_comments-1;$c++){
$content = explode("::", $read_data[$c]);
echo "Nome: $content[0]";
echo "
";
echo "Commento: $content[1]";
echo "
";
}
}
?>
<hr>
</body>
</html>