Guest User

Untitled

a guest
Nov 17th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. <?php
  2. header("Content-Type application/xhtml+xml; charset=utf-8");
  3.  
  4. session_start();
  5.  
  6. $database_user = "root";
  7. $database_pass = "uvekjenajgorenista";
  8.  
  9. $db = new PDO('mysql:host=localhost;dbname=bookmarker', $database_user, $database_pass);
  10.  
  11. function msg_error($string)
  12. {
  13. die('<div class="error"><b>Error:</b> ' . $string . '</div>');
  14. }
  15.  
  16. function only_logged()
  17. {
  18. if (! $_SESSION['user'])
  19. {
  20. msg_error("Only logged users can see this page");
  21. }
  22. }
  23.  
  24. function show_bookmark($bid)
  25. {
  26. $result = $db->query("SELECT title,content,uid,private FROM bookmarks WHERE id = '$bid'");
  27. echo "fetching...";
  28. $row = $result->fetch();
  29.  
  30. if (! $row)
  31. {
  32. msg_error("Cannot read bookmark specifiee by ID $bid, maybe it does not exist.");
  33. }
  34. echo "$row[0]";
  35.  
  36. echo '<div class="bookmark-entry">';
  37. echo '<p><h2>' . $row[0] . '</h2></p>';
  38. echo '<p>';
  39. echo $row[1];
  40. echo '</p>';
  41. echo '</div>';
  42. }
  43. ?>
Add Comment
Please, Sign In to add comment