MYSQL和PHP:数据未插入

I a trying to add data into these two foreign key fields but it is causing an error. The thing is, When i go on MYSQL and try inserting data, it actually does work, however, when i try the same with php, I get the following error:

Notice: Undefined variable: CantactId in C:\xamppp\htdocs\MDK\profiles.php on line 14
Error updating database: Cannot add or update a child row: a foreign key constraint fails (`companies`.`company`, CONSTRAINT `company_ck` FOREIGN KEY (`CantactId`) REFERENCES `contacts` (`ContactId`) ON DELETE NO ACTION ON UPDATE CASCADE)

this error only exists between the foreign key fields of my table, not the rest. What exactly am i doing wrong? Here is my php code; If you need to check something else too, please let me know as i really am clueless about how to use this website and ask my question.

<?php
include('database1.php');

if(isset($_POST['insert']))
{
    $CompanyCode=$_POST['CompanyCode'];
    $CompanyName = $_POST['CompanyName'];
    $Address = $_POST['Address'];
    $Fax = $_POST['Fax'];
    $Website=$_POST['Website'];
    $Telephone = $_POST['Telephone'];
    $ContactId = $_POST['CantactId'];
    $CountryCode=$_POST['CountryCode'];
     $sql = "INSERT INTO `company`(`CompanyCode`, `CompanyName`, `Address`, `Fax`, `Website`, `Telephone`, `CantactId`, `CountryCode`) VALUES ('$CompanyCode','$CompanyName','$Address','$Fax','$Website','$Telephone','$CantactId','$CountryCode')";
     $query=mysql_query($sql) or die ('Error updating database: '.mysql_error());;
   if($query==TRUE)
   {
    header('Refresh:0; details1.php');
   }
   else
       echo "Sorry";
}

?>
  <form action="" method="post">
   Company Code: <input type="text" name="CompanyCode" ><br><br>
   Company Name: <input type="text" name="CompanyName"><br><br>
   Address: <input type="text" name="Address" ><br><br>
   Fax: <input type="number" name="Fax"  ><br><br>
   Website: <input type="text" name="Website"  ><br><br>
    Telephone: <input type="text" name="Telephone"  ><br><br>
   ContactId: <input type="number" name="CantactId"  ><br><br>
   Country Code: <input type="number" name="CountryCode"><br><br>
    <input type="submit" name="insert" value="Insert">
    </form>

</form>

You have typo error here. Change $CantactId to $ContactId

$sql = "INSERT INTO `company`(`CompanyCode`, `CompanyName`, `Address`, `Fax`, `Website`, `Telephone`, `CantactId`, `CountryCode`) VALUES ('$CompanyCode','$CompanyName','$Address','$Fax','$Website','$Telephone','$ContactId','$CountryCode')";

Also dont use mysql_ It is deprecated and completely removed in PHP 7. Use mysqli_ or PDO instead