<?php
$servername = "localhost";
    $username = "root";
    $password = "";
    $database = "raimondsedvins_4110";

// Izveidot savienojumu
    $connection = new mysqli($servername, $username, $password, $database);

    //parbaude
    if ($connection->connect_error) {
      die("Connection failed: " . $connection->connect_error);
    }

// id no pieprasijuma
$inviteId = $_GET['id'];

// atgriez nepieciesamo uzaicinajumu no friend_invites table
$sql = "SELECT nickname from login WHERE nickname='$inviteId'";
$result = $connection->query($sql);

if ($result->num_rows > 0) {
  $row = $result->fetch_assoc();

  // Ievieto uzzaicinajumu friend_list_data tabula
  $friendName = $row["nickname"];
  $insertSql = "INSERT INTO friend_invites (invites) VALUES ('$friendName')";
  $insertResult = $connection->query($insertSql);


    if ($deleteResult === TRUE) {
      echo "Invite sent successfully.";
    } else {
      echo "Error sending invite: " . $connection->error;
    }
}
 else {
  echo "Person not found.";
}

$connection->close();
?>