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.

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