comment script
Posted: Mon Apr 06, 2009 5:01 pm
Hi frends,
i m new to php...
so please forgive me if i asked any foolish question.
i wanted to know...abt comment script.
here this is my file.
1.php:
<html><head>
<title>Praaactice</title>
</head><body><h1> Welcome </h1>
<hr>
<?php
// giving variable names to form data
$name = $_POST['name'];
$email = $_POST['email'];
$blog = $_POST['blog'];
$comments = $_POST['comments'];
//displaying & printing form data on page
echo "Posted by: ";
echo "<a href=" . $blog . ">" . $name . "</a>";
echo "<BR>";
echo $comments;
?>
<?php
//writing form data to text file, 'data1.txt'
$handle= fopen("data1.txt","a");
fwrite($handle,'name' . "\n");
fwrite($handle, '~');
fwrite($handle,'email' . "\n");
fwrite($handle, '~');
fwrite($handle,'blog' . "\n");
fwrite($handle, '~');
fwrite($handle,"comments" . "\n\n");
fwrite($handle, '|~|');
fclose($handle);
?>
<hr>
<!-- html form below -->
<form action="1.php" method="post">
Name:<br> <input type="text" name="name" /><br>
Email:<br> <input type="text" name="email" id="email"/><br>
Website/Blog url:<br><input type='text' name='blog' id='blog' value='http://' /><br>
Comments:<br><textarea rows=5 cols=27 name='comments' id='comments'>
</textarea><br>
<input type="submit" value='Submit'/>
</form>
<!-- end of form -->
</body>
</html>
the problem i face is,
when i type 1st comment, it shows on the page.
& then, when i type, 2nd comment,
the 2nd comment replaces the 1st comment,
the 1st comment disappears from the screen.
the 3rd comment makes the 2nd comment disappear.
so on.
how can i get all the comments on the page?
i m new to php...
so please forgive me if i asked any foolish question.
i wanted to know...abt comment script.
here this is my file.
1.php:
<html><head>
<title>Praaactice</title>
</head><body><h1> Welcome </h1>
<hr>
<?php
// giving variable names to form data
$name = $_POST['name'];
$email = $_POST['email'];
$blog = $_POST['blog'];
$comments = $_POST['comments'];
//displaying & printing form data on page
echo "Posted by: ";
echo "<a href=" . $blog . ">" . $name . "</a>";
echo "<BR>";
echo $comments;
?>
<?php
//writing form data to text file, 'data1.txt'
$handle= fopen("data1.txt","a");
fwrite($handle,'name' . "\n");
fwrite($handle, '~');
fwrite($handle,'email' . "\n");
fwrite($handle, '~');
fwrite($handle,'blog' . "\n");
fwrite($handle, '~');
fwrite($handle,"comments" . "\n\n");
fwrite($handle, '|~|');
fclose($handle);
?>
<hr>
<!-- html form below -->
<form action="1.php" method="post">
Name:<br> <input type="text" name="name" /><br>
Email:<br> <input type="text" name="email" id="email"/><br>
Website/Blog url:<br><input type='text' name='blog' id='blog' value='http://' /><br>
Comments:<br><textarea rows=5 cols=27 name='comments' id='comments'>
</textarea><br>
<input type="submit" value='Submit'/>
</form>
<!-- end of form -->
</body>
</html>
the problem i face is,
when i type 1st comment, it shows on the page.
& then, when i type, 2nd comment,
the 2nd comment replaces the 1st comment,
the 1st comment disappears from the screen.
the 3rd comment makes the 2nd comment disappear.
so on.
how can i get all the comments on the page?