<?php
include('connection.php');
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Home Services App</title>

    <!-- Font Awesome CDN -->
    <link
      rel="stylesheet"
      href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css"
    />
    <link rel="stylesheet" href="../css/page3.css" />
  </head>
  <body>
    <div class="app">
      <!-- HEADER -->
      <div class="header">
        <button class="back-btn"><i class="fa-solid fa-arrow-left"></i></button>
        <h4>Home Services</h4>
        <div class="header-right"></div>
      </div>

      <!-- SEARCH -->
      <div class="search-bar">
        <input type="text" placeholder="Search for any service..." />
        <button class="search-btn">
          <i class="fas fa-search"></i>
        </button>
        
      </div>

      <div class="home-banner">
        <div class="home-banner-1">
        <div class="home-banner-text">
          <h2>Home Assist</h2>
          <p>Get your household problems solved instantly!</p>
        </div>
        <div class="home-banner-img">
          <i class="fa-solid fa-wrench"></i>
        </div>
        </div>
      </div>

      <!-- CATEGORY / MOST BOOKED SERVICES -->
      <div class="section">
        <h4>Most Booked Services</h4>
        <span>View all</span>
      </div>
       <?php
      $id = $_GET['id'];
      ?>
    <form action="" method="POST">
      <input type="hidden" name="id" value="<?php echo $id ?>">
      <div class="services">
         <?php
        include('connection.php');
        $sql = "SELECT * FROM `category`";
        $res = mysqli_query($con,$sql);

        
        while($row = mysqli_fetch_assoc($res)){

          echo'
        <div class="service">
          <img src="../image/'.$row['icon'].'" />
          <p><input type="checkbox" value="'.$row['name'].'" name="service"><br>'.$row['name'].'</p>
        </div>';
        }
        ?>


      <div class="btn-container">
      <!-- CONTINUE BUTTON (KEEP THIS) -->
      <button class="continue-btn">Continue</button>
      </div>
    </div>

    <script src="../js/page3.js"></script>
  </body>
</html>
<?php
    error_reporting(0);
    include('connection.php');
    $id = $_POST['id'];
    $cat = $_POST['service'];
    
   
    

    if(isset($_POST['submit']))
    {
      $sql = "UPDATE `user` SET `category` = '$cat' WHERE `user`.`id` = '$id'";
      $res = mysqli_query($con,$sql);
      if($res){
        $sid = mysqli_insert_id($con);
        echo "
        <script>
        window.location.href = 'page4.php?id=".$id."';
        </script>
        ";
      }
      else{
        echo "not done";
      }
    }
    ?>
