Guest User

Untitled

a guest
Sep 1st, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require("startup.php");
  4. if (!(isset($_SESSION["active"]))) {
  5. session_register("active");
  6. }
  7. ?>
  8. <html>
  9. <head>
  10. <?php
  11. echo "<title>".$name."</title>";
  12. ?>
  13. <title> </title>
  14. <link rel="stylesheet" type="text/css" href="default.css">
  15. <link rel="alternate" type="application/rss+xml" href="feed.xml" title="xray's blog">
  16. </head>
  17. <body>
  18. <?php
  19. session_start();
  20. echo "<div class=\"login\">";
  21. if (isset($_SESSION["active"]) and $_SESSION["active"]) {
  22. echo "<a href=\"post.php\">Post</a>";
  23. }
  24. else {
  25. echo " <form action=\"login.php\" method=\"post\">";
  26. echo " Username: <input type=\"text\" name=\"username\" />";
  27. echo " Password: <input type=\"password\" name=\"password\" />";
  28. echo " <input type=\"submit\" name='login' value='login'>";
  29. echo "</form>";
  30.  
  31. }
  32. echo"</div>";
  33. if ($_SESSION["posting"]) {
  34. echo "<div class=posts>";
  35. echo "<form action=make_post.php method=post>";
  36. echo "Subject: ";
  37. echo "<input type=text name=title size=72><br />";
  38. echo "<textarea cols=82 rows=15 name=body></textarea></textarea><br /><div class=date>";
  39. echo "<input type=submit name=post value=post></div>";
  40. echo "</div>";
  41. }
  42. if ($_GET) {
  43. $result = mysql_query("select * from Blog where id=".$_GET["id"]);
  44. $row = mysql_fetch_array($result);
  45. if (mysql_num_rows($result) <= 0) {
  46. echo "Invalid Blog Id";
  47. die;
  48. }
  49. echo "<div class=posts><div class=title>".$row['title']."</div><div class=date>".$row["postdate"]."</div><div class=body>".$row["body"]."</div><br /><br />";
  50. $result = mysql_query("SELECT * FROM Comments WHERE blogid=".$_GET["id"]);
  51. while ($row = mysql_fetch_array($result)) {
  52. echo "<div class=post><i>".$row["postdate"]."</i><br />".$row["body"]."<br /><br />";
  53. }
  54. echo "
  55. <form action=comment.php method=post>
  56. Comment:<br />
  57. <textarea cols=20 rows=5 name=body></textarea><br />
  58. <input type=hidden name=id value=".$_GET["id"].">
  59. <div class=rightj><input type=submit name=comment value=comment></div>
  60. </form>
  61. </div>";
  62. } else {
  63. $result = mysql_query("SELECT * from Blog ORDER BY id DESC");
  64. while ($row = mysql_fetch_array($result)) {
  65. echo "<div class=posts>";
  66. echo "<div class=title>".$row['title']." </div><div class=date>".$row['postdate']."</div>";
  67. echo "<div class=body>".$row['body']."</div>";
  68. echo "<br />";
  69. $comments = mysql_query("SELECT * from Comments where blogid=".$row["id"]);
  70. echo "<a href=\"index.php?id=".$row["id"]."\"> Comments (".mysql_num_rows($comments).")</a>";
  71. echo "</div>";
  72. }
  73. mysql_close($connection);
  74. }
  75. ?>
  76. </body>
  77. </html>
Add Comment
Please, Sign In to add comment