A simple php website which displays quotes on pictures of pandas.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.3 KiB

  1. <?php
  2. if($loggedIn)
  3. {
  4. $errors = array();
  5. if(isset($_POST['new_quote']))
  6. {
  7. $i_name = mysqli_real_escape_string($dbc,
  8. trim($_POST['add_quote_name']));
  9. $i_quote = mysqli_real_escape_string($dbc,
  10. trim($_POST['add_quote_quote']));
  11. $q = "select * from people where name ='$i_name'";
  12. $r = mysqli_query($dbc, $q);
  13. if(@mysqli_num_rows($r) == 1)
  14. {
  15. while($row = mysqli_fetch_array($r))
  16. {
  17. $person_id = $row['person_id'];
  18. }
  19. if($_POST['add_quote_visibility'])
  20. {
  21. $q_create = "insert into quote (user_id, creation_date,
  22. person_id, quote, visibility) values ('" . $_SESSION['user_id'] . "',
  23. now(), '$person_id', '$i_quote', true)";
  24. }
  25. else
  26. {
  27. $q_create = "insert into quote (user_id, creation_date,
  28. person_id, quote, visibility) values ('" . $_SESSION['user_id'] . "',
  29. now(), '$person_id', '$i_quote', false)";
  30. }
  31. //echo $q_create;
  32. mysqli_query($dbc, $q_create);
  33. header("Location: quotes.php");
  34. }
  35. }
  36. echo '<h1 class="w3-text-teal"><center>New Quote</center></h1>';
  37. echo '<form action="quotes.php" method ="post" class="w3-container
  38. w3-card-4">';
  39. $q = "select name from people order by name asc";
  40. $r = mysqli_query($dbc, $q);
  41. echo '<select class="w3-select" name ="add_quote_name">';
  42. while($row = mysqli_fetch_array($r))
  43. {
  44. echo '<option value="' . $row['name'] . '">';
  45. echo $row['name'] . '</option>';
  46. }
  47. echo '</select>';
  48. echo '<div class="w3-group">
  49. <input class="w3-input" type="text" name="add_quote_quote" required>
  50. <label class="w3-label w3-validate">Quote</label>
  51. </div>
  52. <input class="w3-check" type="checkbox" name="add_quote_visibility" checked>
  53. <label class="w3-validate">Public<label>
  54. <p><input type="submit" name="Submit" value="Create Quote"
  55. class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align" />
  56. </p>
  57. <input type="hidden" name="new_quote" value="TRUE" />
  58. </form>';
  59. foreach($errors as $msg)
  60. echo " - $msg<br />";
  61. }