yenz

blogpost

Jan 7th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Comment</title>
  4. </head>
  5. <body>
  6. <?php
  7. $act = $_POST['act'];
  8. if($act == "post") {
  9. $name = $_POST['name'];
  10. $message = $_POST['message'];
  11. $code = $_POST['code'];
  12. @$fp = fopen("comments.php", 'a');
  13. if (strtolower($_POST['code']) != 'mycode') {
  14. //The file could not be opened
  15. echo "Password is wrong!";
  16. exit;
  17. } else {
  18. //The file was successfully opened, lets write the comment to it.
  19. $outputstring = "<br>Name: " .$name. "<br> Comment:<br>" .$message. "<br>";
  20.  
  21. //Write to the file
  22. fwrite($fp, $outputstring, strlen($outputstring));
  23.  
  24. //We are finished writing, close the file for security
  25. fclose($fp);
  26.  
  27. //Post success
  28. echo "Your post was successfully entered. Click <a href='index.php'>here</a> to continue.";
  29. }
  30. } else {
  31. //show the form.
  32. ?>
  33. <h2>Previous comments:</h2>
  34. <?php include("comments.php"); ?>
  35. <br><br>
  36. <h2>Post a comment:</h2>
  37. <form action="index.php" method="post">
  38. <table>
  39. <tr>
  40. <td>Name:</td>
  41. <td><input type="text" name="name" value=""></input></td>
  42. </tr>
  43. <tr>
  44. <td>Comment:</td>
  45. <td><textarea name="message"></textarea></td>
  46. </tr>
  47. <tr>
  48. <td>Password:</td>
  49. <td><input type="text" name="code" value=""></input></td>
  50. </tr>
  51. </table>
  52. <input type="hidden" name="act" value="post"></input>
  53. <input type="submit" name="submit" value="Submit"></input>
  54. </form>
  55. <?php
  56. }
  57. ?>
  58. </body>
  59. </html>
Advertisement
Add Comment
Please, Sign In to add comment