activation.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. require_once('php/db_utils.php');
  3. if(isset($_GET['salt'])) { // Parameter received
  4. $salt = $_GET['salt']; // Get parameter
  5. $conn = db_connect(); // Connect to the database
  6. // Check if the user already exists
  7. if(!($result = mysqli_query($conn, "SELECT * FROM user WHERE salt = '$salt'"))) {
  8. $verification = 'false'; // Wrong query
  9. }
  10. else { // Query successful
  11. if(mysqli_num_rows($result) != 1) { // User doesn't exist, or duplicated
  12. $verification = 'false';
  13. }
  14. else { // User returned successfully
  15. // Update activation status
  16. if(!mysqli_query($conn, "UPDATE user SET activated = TRUE WHERE salt = '$salt'")) {
  17. $verification = 'false'; // Wrong query
  18. }
  19. else { // Update successful
  20. $verification = 'true';
  21. }
  22. }
  23. }
  24. mysqli_free_result($result);
  25. db_close($conn); // Close the database
  26. }
  27. else { // Salt not been sent as parameter
  28. $verification = 'false';
  29. }
  30. header('Location: /index.html?verification='. $verification);
  31. ?>