<?php
$host = "blueris.beget.tech";
$username = "blueris_base";
$password = "Qwer123.";
$database = "blueris_base";
$mysql = new mysqli($host, $username, $password, $database);


if($mysql->connect_error){
    die("Ошибка подключения". $mysql->connect_error);
}

if(!isset($_COOKIE['id']))
{
    echo "<script>window.location.href = 'index.php';</script>";
}
else
{


?>

<html lang="ru">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="./styles/Account.css">
    <title>Методический центр "Технология"</title>
   
</head>
<body>

    <header class="header">
        <div class="header-logo">
            <img src="img/лого.png" alt="Логотип методического центра">
        </div>
        <div class="header-info">
            <h1 class="header-tech">ТЕХНОЛОГИЯ</h1>
            <div class="header-center">
                | Методический центр 
            </div>
            <div class="header-location">
                 г. Нижний Новгород, пр. Кирова, 12
            </div>
            <div class="header-phone">
                | +7 (831) 291-50-25
            </div>
        </div>
        <div class="header-nav">          
            <button id="menu">Меню</button>
            <ul>
                <li><a href="index.php">Главная</a></li>
                <li><a href="about.php">О нас</a></li>
                <li><a href="videos.php">Видео пособия</a></li>
                <li><a href="obychenie.php">Обучение</a></li>
                <li><a href="contacts.php">Контакты</a></li>
                <li><a href="questions.php">Вопросы</a></li>
            </ul>
        </div>
    </header>
    <div class="container">
      <div class="container1">
      <?php
    session_start();
    $id = (int)$_COOKIE['id'];
    $result =  mysqli_query($mysql, "SELECT * FROM login WHERE id_user = $id");  
    $hello = mysqli_fetch_assoc($result);
    echo "<div class = 'hello';'>Здравствуйте, ". $hello['name'] . " " . $hello['lastname']."</div>"; 
    echo "<div class = 'loginn';'>Ваш логин: ". $hello['login'] ."</div>"; 
    echo "<div class = 'email';'>Ваш email: ". $hello['email'] ."</div>"; 
?>
        <div class="loginBut"><a href="changelogin.php"><button type="button">Сменить логин</button></a></div>
        <div class="loginBut"><a href="changepassword.php"><button type="button">Сменить пароль</button></a></div>
 </div>

        <div class="container2">
        <?php
  $result1 =  mysqli_query($mysql, "SELECT id_service from buy_service WHERE id_user = $id");  

  if(mysqli_num_rows($result1) > 0)
  {
    echo "<div class = 'hello';'>Ваши курсы</div>";
    While( $id_serv = mysqli_fetch_assoc($result1)){
  $id_servi = $id_serv['id_service'];
  $result2 =  mysqli_query($mysql, "SELECT * FROM service WHERE id_service = $id_servi");
  $result3 =  mysqli_query($mysql, "SELECT * FROM Teachers WHERE id_service = $id_servi");
?>
  <div class="course">
  <?php  
  $rivews = mysqli_fetch_assoc($result2);
  $teach = mysqli_fetch_assoc($result3)

    ?>
      <div class="sevices-container" id="a">
    <div class="course-info"> 

    <h3 class="course-title"><?php echo $rivews['name'];  ?></h3>
    <img src= <?php echo $rivews['image']; ?> class="course-image">
        <p class="course-description">   <?php echo $rivews['description'];?> </p>
        <p class="course-price">Время(часы): <?php echo $rivews['time'];?></p><br>
        <p class="course-price">Ваш преподаватель: <?php echo $teach['FullName'];?>
        <p class="course-price">Номер для связи с преподавателем: <?php echo $teach['PhoneNumber'];?>
        <p class="course-price">Email для связи с преподавателем: <?php echo $teach['Email'];?>
        </div>     
   <?php  
 
   ?>
  </div>
   </div>

        
       
      

<?php
}
}
else
{
  echo "<div class = 'hello';'>У вас нет активных курсов</div>";
}
}
?>
</body>
</html>