Inserting data into mysqli database with bootstrap

i want to insert some form data into database. I am using php/bootstrap/mysqli. i am not good at bootstrap.i have tried several method but its not working. there is no error also , hence i don’t understand what am i doing wrong.it would be very appreciative if anyone could help me.

here is my form

Items Table

Add
×

Add Item

Item Code
Name
Unit Id
Unit Price
Category Category 1 option 2
Close Save

here is my connection

<?php
 $con=mysqli_connect('localhost','...','...','soft');
  if(isset($_POST['submit'])){
   $code=$_POST['code'];
   $unit=$_POST['unit'];
    $name=$_POST['name'];
    $price=$_POST['price'];
     $cate=$_POST['cate'];

mysqli_query($con,"insert into item (code,unit,name,price,cate)      
values('$code','$unit','$name','$price','$cate')"); 

}
?>

<?php
$link = mysqli_connect("localhost", "root", "", "sof");

// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}
if(isset($_POST['txtbutton']))
   {
	$code =  rand(10000,100000);
  $unit = $_POST['unit'];
  $name = $_POST['name'];
  $price = $_POST['price'];
  $cate = $_POST['cate'];
  $sql = "INSERT INTO `items` (`code`, `unit`, `name`, `price`, `cate`) VALUES ('$code', '$unit', '$name', '$price', '$cate')";
  if (mysqli_query($link, $sql)) {
  echo "success";
  } else {
    echo "error";
  }
}else{
  echo '<form method="post" action="a.php">  
  unit: <input type="text" name="unit">
    <br><br>
    name: <input type="text" name="name">
    <br><br>
    price: <input type="text" name="price">
    <br><br>
    cate: <input type="text" name="cate">
    <input type="submit" name="txtbutton" value="Submit">  
  </form>';
}

?>

:slight_smile: