How to connect database to HTML/PHP

I’m having issues with linking the database (phpmyadmin) to my files in visual code (PHP files)

I’m a new web programmer so most likely I forgot something pretty obvious.

This is my registration.html class

<!DOCTYPE HTML>
<html>
<head>
  <meta charset="UTF-8">
  <title>Registration</title>
   <meta http-equiv="refresh" content="43200">
  <link rel="stylesheet" type="text/css" href="style.css" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
  
</head>
<div class="bg_img" id="site_content">
        
    <h3 id="msg" style="display:none; color:rgb(246, 211, 255);">
        New record created successfully
    </h3>

<body id="top">
    <div id="header">
      <div id="logo">
        <img src="img/logo.png" width="130"/>       
        <a href="#" class="hbutton">sign in</a>
        <a href="#" class="hbutton">sign up</a> 
      </div>
     
           <div id="menubar">
        <ul id="menu">
          <li ><a href="Home.html">Home</a></li>
          <li class="selected"><a href="about.html">about us</a></li>
          <li><a href="contactus.html">Contact us</a></li>
          <li><a href="productlist.html">Product List</a></li>
          <li><a href="registration.html">Product Registration</a></li>
           <li><a href="profile.html">Profile</a></li>
         <li class="dropdown">
          <a href="product.html" class="drop-btn">Product Gallery</a>
          <div class="dropdown-content">
                                <a href="OralCare.html">Oral Care</a>
                    <a href="SkinCare.html">Skin care</a>
                    <a href="PresonalCare.html">Personal Care</a>
              <a href="NailCare.html">Nails care</a>
              <a href="Haircare.html">Hair Care</a>
                </div>
            </li>

        </ul>
      </div>

      <script>
        function save(a){
        alert(a);
        }
        var window,location,herf;
       if (url.includes('msg'))document.getElementById("msg").style.desplay='block'; 

        </script>
         
         </div>
            <div class="contrainer">
            <header>Product Registration</header>
            <form method = "post" action="register.php">
                <div class = "productreg">
                <span class="title"> </span>
                   <div class="fields">
                   <div class="input-fields">
                        <label>Product Name: </label>
                        <input type = "text" placeholder="enter the name of the product" required name="name">
                
            </div>
            <div class="input-fields">
                <label>price: </label>
                <input type = "text" placeholder="enter the price of the product" required name="price">
        
        </div>
        <div class="input-fields">
            <label>Product description</label>
            <input type = "text" placeholder="enter small description of the product" required name="description">
        
        </div>
        </div>
        <div class="input-fields">
            <label>code number</label>
            <input type = "text" pattern="[0-9]{2}-[0-9]{3}" placeholder="Enter product code (e.g., 11-123)" required name="code">
        
        </div>
        <div class="input-fields">
        <label>country of origin</label>
        <input type = "text" placeholder="enter the country of origin of the product" required name="country">
        
        </div>
        <div class="input-fields">
            <label>expiration date</label>
            <input type = "date" placeholder="enter the expiration date of the product" required name="expire">
            
            </div>
          
            <button type="submit">Register Product</button>
            <button type="button" onclick="clearProducts()">Clear Products</button>
                
        </div>
    </div>
        

        </form>
        
    </body>
                  <br>
                 
                
<footer>
  <div class="footerContainer">
      <div class="socialIcons">
          <a href=""><i class="fa-brands fa-facebook"></i></a>
          <a href=""><i class="fa-brands fa-instagram"></i></a>
          <a href=""><i class="fa-brands fa-twitter"></i></a>
          <a href=""><i class="fa-brands fa-google-plus"></i></a>
          <a href=""><i class="fa-brands fa-youtube"></i></a>
      </div>
            
  </div>
  <script>
    function clearProducts() {
      // Send a request to clear.php (implementation not shown here)
    }
  </script> 
  <script>
    setTimeout(function() {
        location.reload();
    }, 12 * 60 * 60 * 1000);
</script>
  <div class="footerBottom">
      <p>Copyright © 2024 Soft Care</span></p>
  </div>
</footer>


</html>

and this is my php file register.php

<?php
    $servername = "localhost";
    $username = "root";
    $password = "";
    $dbname = "product";

    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) {
      die("Connection failed: " . $conn->connect_error);
    }
    
    $name=$_POST['name'];
    $price=$_POST['price'];
    $Code=$_POST['Code'];
    $country=$_POST['country'];
    $city=$_POST['city'];
    $expiration_date=$_POST['expiration_date']; 


    $sql = "INSERT INTO `products` ( `name`, `price`, `Code`, `country`, 'city', 'expiration_date') 
            VALUES ( '$name', '$price', '$Code', '$country', 'city', '$expiration_date','$Category');";

    //echo $sql; exit;
    if ($conn->query($sql) === TRUE) {
        header("Location: product_register.html#msg");
        die();
    } else {
      echo "Error: " . $sql . "<br>" . $conn->error;
    }

    $conn->close();
?>

and I have a database in phpmyadmin the table called product

product

I tried everything with the PHP code / is there something I should do to connect it not only the code?

I’m developing a skin care website so I wanter to make a page like this

example

(It’s a bit messy because I was trying to connect the DB to the Php) store the data into the database with later will appear on the List Product section

also how to make the clear button

New contributor

modhi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật