Advertisement
Guest User

index.php

a guest
Mar 3rd, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. <?php
  2. if (get_magic_quotes_gpc())
  3. {
  4. function stripslashes_deep($value)
  5. {
  6. $value = is_array($value) ?
  7. array_map('stripslashes_deep', $value) :
  8. stripslashes($value);
  9.  
  10. return $value;
  11. }
  12.  
  13. $_POST = array_map('stripslashes_deep', $_POST);
  14. $_GET = array_map('stripslashes_deep', $_GET);
  15. $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
  16. $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
  17. }
  18.  
  19. if (isset($_GET['additem']))
  20. {
  21. include 'form.html.php';
  22. exit();
  23. }
  24.  
  25. $link = mysqli_connect('localhost', 'root', 'mylibpro');
  26. if (!$link)
  27. {
  28. $error = 'Unable to connect to the database server.';
  29. include 'error.html.php';
  30. exit();
  31. }
  32.  
  33. if (!mysqli_set_charset($link, 'utf8'))
  34. {
  35. $output = 'Unable to set database connection encoding.';
  36. include 'output.html.php';
  37. exit();
  38. }
  39.  
  40. if (!mysqli_select_db($link, 'lendinglibrary'))
  41. {
  42. $error = 'Unable to locate the library database.';
  43. include 'error.html.php';
  44. exit();
  45. }
  46.  
  47. if (isset($_POST['Title']))
  48. {
  49. $Title = mysqli_real_escape_string($link, $_POST['Title']);
  50. $sql = 'INSERT INTO library SET
  51. Title="' . $title . '",
  52. jokedate=CURDATE()';
  53. {
  54. $error = 'Error adding submitted item: ' . mysqli_error($link);
  55. include 'error.html.php';
  56. exit();
  57. }
  58.  
  59. header('Location: .');
  60. exit();
  61. }
  62.  
  63. $result = mysqli_query($link, 'SELECT Title FROM library');
  64. if (!$result)
  65. {
  66. $error = 'Error fetching library items: ' . mysqli_error($link);
  67. include 'error.html.php';
  68. exit();
  69. }
  70.  
  71. while ($row = mysqli_fetch_array($result))
  72. {
  73. $title[] = $row['Title'];
  74. }
  75.  
  76. include 'items.html.php';
  77. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement