PageRenderTime 86ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/mybookbag/check.php

https://bitbucket.org/s2223902/mybookbag
PHP | 151 lines | 146 code | 5 blank | 0 comment | 4 complexity | 8277f843060e74d3fff96c3d03f0c585 MD5 | raw file
  1. <?php
  2. session_start();
  3. include 'db_connection.php';
  4. include 'functions.php';
  5. if(!isset($_POST["submit"])){ //Accepts or rejects the form and sends back if rejected.
  6. $_SESSION["Message"] = "<p>Insert information first! Did not get enough information. Try again.</p>";
  7. header("Location:adddoc.php");
  8. }
  9. unset($_POST["submit"]);
  10. $query = "select book.entryid,title,author,genre,publisher,isbn,type from book natural left outer join author_book, genre_book, publisher_book where book.entryid=author_book.entryid and book.entryid=genre_book.entryid and book.entryid=publisher_book.entryid and genre like '%{$_POST["genre"]}%' and author like '%{$_POST["author"]}%' and publisher like '%{$_POST["publisher"]}%' and title like '%{$_POST["title"]}%' and `type` like '{$_POST["type"]}'";
  11. $result = mysql_query($query) or die(mysql_error());
  12. $result_table = "<table><form action=\"insert.php\" method=\"post\"><tr>
  13. <td>Title</td>
  14. <td>Author</td>
  15. <td>Genre</td>
  16. <td>Publisher</td>
  17. <td>ISBN</td>
  18. <td>Type</td>
  19. <td><b>Choose</b></td>
  20. </tr>
  21. ";
  22. $count = 0;
  23. $rows = array();
  24. if(mysql_num_rows($result)>0){ //Processes entire searchresults
  25. while($row = mysql_fetch_array($result)){
  26. $title = $row['title'];
  27. $rows[] = $row;
  28. $result_table = $result_table."<tr><td>{$row['title']}</td>";
  29. $result_table = $result_table."<td>{$row['author']}</td>";
  30. $result_table = $result_table."<td>{$row['genre']} </td>";
  31. $result_table = $result_table."<td>{$row['publisher']} </td>";
  32. $result_table = $result_table."<td>{$row['isbn']}</td>";
  33. $result_table = $result_table."<td>{$row['type']}</td>";
  34. $result_table = $result_table."<td><input type=\"radio\" name=\"choice\" value=\"".$count."\"></input></tr>";
  35. $count+=1;
  36. }
  37. $result_table = $result_table."<tr><td><select name=\"permission\">
  38. <option value=\"0\">Private</option>
  39. <option value=\"2\">Public</option>
  40. <option value=\"1\">Friends</option></select></td><td>
  41. <input type=\"submit\" name=\"submitpicked\"></td></tr></table></form>";
  42. $_SESSION["rows"] = $rows;
  43. $_SESSION["results"] = $result_table;
  44. }
  45. else{
  46. $_SESSION["results"] = "<p>No titles were found for your query! We apologize!</p>";
  47. }
  48. $_SESSION["new_table"] = "<form action=\"insert.php\" method=\"post\"><table><tr>
  49. <td>Title*</td>
  50. <td><input type=\"text\" name=\"title\"></td>
  51. </tr>
  52. <tr>
  53. <td>Author*</td>
  54. <td><input type=\"text\" name=\"author\"></td>
  55. </tr>
  56. <tr>
  57. <td>Genre</td>
  58. <td><input type=\"text\" name=\"genre\"></td>
  59. </tr>
  60. <tr>
  61. <td>Publisher</td>
  62. <td><input type=\"text\" name=\"publisher\"></td>
  63. </tr>
  64. <tr>
  65. <td>ISBN*</td>
  66. <td><input type=\"text\" name=\"isbn\"></td>
  67. </tr>
  68. <tr>
  69. <td>Type</td>
  70. <td><select name=\"type\">
  71. <option value=\"b\">Book</option>
  72. <option value=\"e\">E-Book</option>
  73. <option value=\"j\">Journal</option>
  74. </td>
  75. <td><select name=\"permission\">
  76. <option value=\"0\">Private</option>
  77. <option value=\"1\">Public</option>
  78. <option value=\"2\">Friends</option></select></td>
  79. </tr><tr><td><input type=\"submit\" name=\"submitnew\"></td></tr>
  80. </table>
  81. ";
  82. ?>
  83. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  84. <html>
  85. <head>
  86. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  87. <link href='http://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'>
  88. <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
  89. <link rel="stylesheet" href="css/formstyles.css" type="text/css" />
  90. <script type="text/javascript" src="js/Placeholders.js"></script>
  91. <script type="text/javascript">
  92. Placeholders.init({
  93. live: true,
  94. hideOnFocus: true});
  95. </script>
  96. <link href="css/toolbar.css" rel="stylesheet" type="text/css" />
  97. <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
  98. <title>Add a new MyDoc</title>
  99. </head>
  100. <body>
  101. <?php include ("php/random-bg.php"); ?>
  102. <div id="mainContainer">
  103. <div id="carbonForm2">
  104. <div id="logo2">
  105. <img src="img/logo.png" />
  106. <p>Welcome <b><?php echo $_SESSION['username'];?></b></p>
  107. </div>
  108. <ul id="nav">
  109. <li><a href="page.php">Home</a></li>
  110. <li class="current"><a href="mybooks.php">MyBookBag</a>
  111. <ul>
  112. <li><a href="mybooks.php">My Books</a></li>
  113. <li><a href="myebooks.php">My eBooks</a></li>
  114. <li><a href="myjournals.php">My journals</a></li>
  115. <li><a href="adddoc.php">Add Books</a></li>
  116. </ul>
  117. </li>
  118. <li><a href="friends.php">My Friends</a>
  119. <ul>
  120. <li><a href="friends.php">My Friends</a></li>
  121. <li><a href="messages.php">Messages (0)</a></li>
  122. <li><a href="addfriend.php">Add friends</a></li>
  123. <li><a href="requests.php">Friend Requests</a></li>
  124. </ul>
  125. </li>
  126. <li><a href="settings.php">Settings</a>
  127. <ul>
  128. <li><a href="passreset.php">Change Password</a></li>
  129. </ul>
  130. </li>
  131. <li><a href="contact.php">Contact</a></li>
  132. <li><a href="logout.php">Log Out</a></li>
  133. </ul>
  134. <div class="fieldContainer">
  135. <p><h1>Add new MyDoc</h2></p>
  136. <?php // Here all the results are printed and this is where the user can choose between picking an already found result, or creating a new entry.
  137. echo "<p><h3>Select the title you want from the selection we have found for you!</h3></p>";
  138. echo "<p>".$_SESSION["results"]."</p>";
  139. echo "<p><h3>Or submit a new entry to MyBookBag and help contribute to our society!</h3></p>";
  140. echo "<p>".$_SESSION["new_table"]."</p>";
  141. ?>
  142. </div>
  143. </div>
  144. </div>
  145. </body>
  146. </html>