Guest User

Untitled

a guest
May 16th, 2012
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1. <?php
  2. // get the filename for the comment log
  3. $parts=parse_url($_SERVER['REQUEST_URI']));
  4. $filename=$parts['path'];
  5. $filename=str_replace(array("/","\","."),"-",$filename);
  6. $filename.=".comments";
  7.  
  8. // save the comment?
  9. if($_POST['comment-now'])) {
  10.  $comment=strip_tags(stripslashes($_POST['comment']));
  11.  $source =strip_tags(stripslashes($_POST['source']));
  12.  
  13.  $f=fopen($filename,"at");
  14.  if($f) {
  15.    fwrite($f,"<div class='comment_block'>");
  16.    fwrite($f,"<blockquote>$comment</blockquote>");
  17.    fwrite($f,"<cite>$source</cite>");
  18.    fwrite($f,"<p class='time'>$now</p>");
  19.    fwrite($f,"</div>");
  20.    fclose($f);
  21.  }
  22. }
  23.  
  24. // display the existing comments
  25. if(file_exists($filename)) {
  26.  echo "<div class='comments'>";
  27.  echo file_get_contents($filename);
  28.  echo "</div>";
  29. }
  30.  
  31. // display the comment form
  32. ?>
  33. <form action='' method='post'>
  34. <table>
  35.  
  36. <tr>
  37. <td>Your name</td>
  38. <td><input type='text' name='source' /></td>
  39. </tr>
  40.  
  41. <tr>
  42. <td>Your comment</td>
  43. <td><textarea name='comment'></textarea></td>
  44. </tr>
  45.  
  46. <tr>
  47. <td>Ready?</td>
  48. <td><input type='submit' name='comment-now' value='Add Comment'></td>
  49. </tr>
  50.  
  51. </table>
  52. </form>
Advertisement
Add Comment
Please, Sign In to add comment