*index.php
Code: Select all
<html>
<head>
<title>Comment Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<div align="center">
<div align="left">
<table width="80%" border="" cellspacing="0" cellpadding="0">
<tr>
<td align="left">
<?php
if ($file = @file_get_contents("comments.phpdata")) {
echo $file."\n";
}
else {echo "Sorry, but no comments were found.";}
?>
</td>
</tr>
</table>
</div>
<p align="left"><a href="add.php">Add Comment</a></p>
</div>
</body>
</html>*add.php
Code: Select all
<html>
<head>
<title>Add Comment Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<div align="center">
<p><font size="+1">Add Comment Demo:</font></p>
<form name="form1" method="post" action="sent.php">
<textarea name="comment" cols="60" rows="10"><?php
if ($file = @file_get_contents("comments.phpdata")) {
echo $file."\n";
}
else {echo "Sorry, But your page is blank";}
?></textarea><br>
<input type="submit" value="submit">
</form>
<a href="index.php">Back</a>
</div>
</body>
</html>*sent.php
Code: Select all
<?php
$filename = "comments.phpdata";
if ($name = stripslashes($_POST['comment'])) {
$comment = str_replace("<","<",$comment); //security
$comment = str_replace(">", ">", $comment); //security
$file = @fopen($filename, "w+");
@fwrite($file, $comment);
@fclose($file);
$message = "Your comment was successfully added.<br>Redirecting to index.php";
}
else {
$message = "You either entered no data or it was entered incorrectly.<br>Redirecting to index.php";
}
?>
<html>
<head>
<title>Comment Added Demo</title>
<meta http-equiv="refresh" content="3;url=index.php">
</head>
<body>
<div align="center">
<p><font size="+1">Comment Added Demo:</font></p>
<?php echo $message; ?>
</div>
</body>
</html>you can view it here:http://benslayton.awardspace.com[/url]