Guest User

Untitled

a guest
Apr 26th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.68 KB | None | 0 0
  1. <?php
  2.     mysql_connect ("ephesus.cs.cf.ac.uk", ");
  3.     mysql_select_db
  4.  
  5.  
  6. $sql = "SELECT * FROM php_blog ORDER BY timestamp DESC LIMIT 5";
  7.  
  8. $result = mysql_query($sql) or print ("Can't select entries from table php_blog.<br />" . $sql . "<br />" . mysql_error());
  9.  
  10. while($row = mysql_fetch_array($result)) {
  11.  
  12.    $date = date("l F d Y", $row['timestamp']);
  13.  
  14.    $title = stripslashes($row['title']);
  15.    $entry = stripslashes($row['entry']);
  16.    $password = $row['password'];
  17.    $id = $row['id'];
  18.  
  19.    if ($password == 1) {
  20.        echo "<p><strong>" . $title . "</strong></p>";
  21.  
  22.        printf("<p>This is a password protected entry. If you have a password, log in below.</p>");
  23.  
  24.        printf("<form method=\"post\" action=\"journal.php?id=%s\"><p><strong><label for=\"username\">Username:</label></strong><br /><input type=\"text\" name=\"username\" id=\"username\" /></p><p><strong><label for=\"pass\">Password:</label></strong><br /><input type=\"password\" name=\"pass\" id=\"pass\" /></p><p><input type=\"submit\" name=\"submit\" id=\"submit\" value=\"submit\" /></p></form>",$id);
  25.        print "<hr />";
  26.    }
  27.    else { ?>
  28.  
  29.         <p><strong><?php echo $title; ?></strong><br /><br />
  30.         <?php echo $entry; ?><br /><br />
  31.         <?php
  32.  
  33.         $result2 = mysql_query ("SELECT id FROM php_blog_comments WHERE entry='$id'");
  34.         $num_rows = mysql_num_rows($result2);
  35.  
  36.         if ($num_rows > 0) {
  37.             echo "<a href=\"journal.php?id=" . $id . "\">" . $num_rows . " comments</a>";
  38.         }
  39.         else {
  40.             echo "<a href=\"journal.php?id=" . $id . "\">Leave a comment</a>";
  41.         } ?>
  42.  
  43.         <hr /></p>
  44.  
  45.         <?php
  46.     }
  47. }
  48.  
  49. ?>
Add Comment
Please, Sign In to add comment