<?
  $servername = "db";
  $username = 'kalskeborec';
  $password = 'Kalskeborec1!23$';
  $db = 'kalskeborec';
  
  // Create connection
  $conn = new mysqli($servername, $username, $password, $db);
  
  // Check connection
  if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
  }

  $year = date("Y");
  $sql = "SELECT ID, NAME, LENGTH, CLIMB from RACES where YEAR like '".$year."'";
  $result = $conn->query($sql);
  if ($result->num_rows > 0){
    $table_registered = '';
    while($row = $result->fetch_assoc()) {
      $races[] = $row;
    }
  }
  // would be nice to check if the email exists
  $sql = "SELECT ID, NAME, SURNAME, EMAIL from REGISTERED where EMAIL_CHECK like '".$email_check."'";
  $result = $conn->query($sql);
  if ($result->num_rows > 0){
    $unique_email = False;
  }
  else{
    $unique_email = True;
  }
  $conn->close();
  //var_dump($races);
?>
