check-is-collaborator.php 946 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. require_once("../../php/db_utils.php");
  3. try {
  4. // Connect to the database
  5. $database = db_connect();
  6. // Incoming data
  7. $canvasId = $_POST["canvas_id"];
  8. $username = $_POST["username"];
  9. // Declare query
  10. $query = 'SELECT collaborator FROM collaborators WHERE canvas_id = "' . $canvasId . '" AND collaborator = "' . $username . '";';
  11. // Run query
  12. $recordSet = db_query_return($database, $query);
  13. // Return the version if it exists
  14. $record = mysqli_fetch_assoc($recordSet);
  15. $collaborator = $record["collaborator"];
  16. mysqli_free_result($recordSet);
  17. echo($collaborator);
  18. // Close the connection to the database
  19. db_close($database);
  20. }
  21. catch(Exception $e) {
  22. $errorMsg = $e->getMessage();
  23. print_r($errorMsg);
  24. }
  25. ?>