MYSQL - ON DUPLICATE KEY does not update
<p>I having been having the worst luck with updating and inserting into a database. My insert into a database works perfectly, i just cannot update.</p>

<p>I have tired two seperate queries one for update the other insert, but updating never works. I am now using the ON DUPLICATE KEY trigger and once again the information just adds a record each time instead of updating. Where am i going wrong? I have been working on this for a day and half now and can't seem to get anywhere. newbee problems!</p>

<pre><code>  &lt;?php
   $Cust_ID = $_SESSION["CustomerID"];
   if (isset($_POST['Update'])) {
      $c_fname = $_POST['fname'];
      $c_lname = $_POST['lname'];
      $c_email = $_POST['email'];
      $c_phone = $_POST['phone'];

  // Save $_POST to $_SESSION
  //query

   $insert_det = "INSERT INTO  Cus_acc_details(CUS_Fname,CUS_Lname,Cus_Email,CUS_Phone) 
    VALUES (?,?,?,?)
    ON DUPLICATE KEY 
    UPDATE
    CUS_Fname = '$c_fname',
    Cus_Lname = '$c_lname'";

$stmt = mysqli_prepare($dbc, $insert_det);
//new
// $stmt = mysqli_prepare($dbc, $insert_c);
//debugging
//$stmt = mysqli_prepare($dbc, $insert_c)  or die(mysqli_error($dbc));

mysqli_stmt_bind_param($stmt, 'sssi', $c_fname, $c_lname, $c_email, $c_phone);

/* execute query */
$r = mysqli_stmt_execute($stmt);

// if inserted echo the following messges
if ($r) {
    echo "&lt;script&gt; alert('registration sucessful')&lt;/script&gt;";
}
} else {
echo "&lt;b&gt;Oops! Your passwords do not &lt;/b&gt;";
}
?&gt;
</code></pre>

<p>HTML</p>

<pre><code>&lt;section class="container"&gt;
    &lt;form id="myform " class="Form" method="post" action="Cus_Account.php?c_id=&lt;?php echo $c_id ?&gt;" accept-charset="utf-8"&gt;

        &lt;!--                    &lt;div id="first"&gt;--&gt;
        &lt;input type="text" id="fname" name="fname" value="&lt;?php echo $_SESSION['fname']; ?&gt;" required&gt; 
        &lt;input type="text" id="lname" name="lname" value="&lt;?php echo $_SESSION['lname']; ?&gt;"  required&gt;
        &lt;input type="text" id="email" name="email" value="&lt;?php echo $_SESSION['Cus_Email']; ?&gt;" required&gt;
        &lt;input type="number" id="phone" name="phone"  value="&lt;?php echo $_SESSION['phone']; ?&gt;"  required&gt;
        &lt;input type="submit" name="Update" value="Update"&gt;
        &lt;br&gt;
    &lt;/form&gt;
</code></pre>

<p>both the Customer_id and Cus-_email field's are set as unique on the bd, however, records keep inserting into the db. any help would be appreciated.</p>

<p>SHOW CREATE</p>

<pre><code>CREATE TABLE `Cus_acc_details` (
`CustomerID` tinyint(11) NOT NULL AUTO_INCREMENT,
`AcctId` varchar(100) NOT NULL,
`CUS_Fname` varchar(45) DEFAULT NULL,
`Cus_Lname` varchar(45) DEFAULT NULL,
`CUS_Phone` varchar(45) NOT NULL,
`Cus_Email` varchar(200) NOT NULL,
PRIMARY KEY (`CustomerID`),
UNIQUE KEY `CustomerID` (`CustomerID`),
UNIQUE KEY `CustomerID_2` (`CustomerID`,`Cus_Email`)
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=outfit
</code></pre>