Why do I get this Notice: Undefined Index error

$connection = mysqli_connect("servername", "username", "password")
or die("Couldn't connect to the server"); //no issue 

$db = mysqli_select_db($connection, "db")
or die("Couldn't select database"); //no issue

$sql = "INSERT INTO vendor_tbl(company_name, industry, details, website, data_type, start_date) VALUES ('".$_POST['company_name']."','".$_POST['industry']."','".$_POST['details']."','".$_POST['website']."','".$_POST['data_type']."','".$_POST['start_date']."')";
// mysqli_query(($connection,$sql);
 if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
$conn->close(); //closes the connection		  
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">

<label id="company_name"> Company Name:</label><br/>
<input type="text" name="company_name" id="company_name"><br/>

<label id="industry"> Industry:</label><br/>
<input type="text" name="industry" id="industry"><br/>

<label id="details"> Details:</label><br/>
<input type="text" name="details" id="details"><br/>

<label id="website"> Website:</label><br/>
<input type="text" name="website" id="website"><br/>

<label id="data_type"> Data Type:</label><br/>
<input type="text" name="data_type" id="data_type"><br/>

<label id="start_date"> Start Date:</label><br/>
<input type="text" name="start_date" id="start_date"><br/>

<button type="submit" name="save">save</button>
<input type="submit" value="submit"/><br/>


i get an error at line: $sql = "INSERT INTO new_vendor_tbl(company_name, industry, details, website, data_type, start_date) VALUES ('".$_POST['company_name']."','".$_POST['industry']."','".$_POST['details']."','".$_POST['website']."','".$_POST['data_type']."','".$_POST['start_date']."')";

Example: Notice : Undefined index: company_name in on line 64

My database has the fields:
company_name (Data type: text)
industry(data type: text)
details (data type: text)
website (data type: text)
data_type (data type: text)
start_date (data type:text)


But, you created a connection variable named $connection…


Your code is wide open to an SQL Injection Attack. You need to use Prepared statements.