title: How to insert and update data in just one button?
body: <p>On the first click  of the button it adds data to database then on second click the button will update the data.Did someone know how to do it.. I have a code for insert but it can't update..</p>
  
  <pre><code>here is my html code
  &lt;html&gt;
  &lt;head&gt;
  &lt;body&gt;
  &lt;form method="POST" action="example.php"&gt;
  &lt;label&gt;Content:&lt;/label&gt;
  &lt;br&gt;
  &lt;textarea name="cafnrcontent" id="cafnrcontent" rows="6" cols="43"&gt;&lt;/textarea&gt;
  &lt;/div&gt;
  &lt;br&gt;
  &lt;label&gt;Posting:&lt;/label&gt;
  &lt;br&gt;
  &lt;label&gt;From date:&lt;/label&gt;
  &lt;input type="date" name="cafnrstart_date"&gt;
  &lt;label&gt;To date:&lt;/label&gt;
  &lt;input type="date" name="cafnrend_date"&gt;
  &lt;br&gt;&lt;br&gt;
    &lt;input type="file" name="cafnrimage"&gt;
  &lt;br&gt;&lt;br&gt;
  &lt;label&gt;Submitted by:&lt;/label&gt;
  &lt;input type="text" id="cafnrauthor" name="cafnrauthor" value=""&gt;
  &lt;br&gt;
  &lt;br&gt;
  &lt;input type="submit" id="send" name="send" value="Submit"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/head&gt;
  &lt;/html&gt;
  
  &lt;?php
  include 'dbconnect.php';
  
    if(isset($_POST['send']))
  {
  
  $cafnrcontent =
  mysqli_real_escape_string($DBcon,strip_tags($_POST['cafnrcontent'])); 
  $cafnrimage = mysqli_real_escape_string($DBcon,strip_tags($_POST['cafnrimage']));
    $cafnrstart_date = mysqli_real_escape_string($DBcon,strip_tags($_POST['cafnrstart_date']));
    $cafnrend_date = mysqli_real_escape_string($DBcon,strip_tags($_POST['cafnrend_date']));
    $cafnrauthor = mysqli_real_escape_string($DBcon,strip_tags($_POST['cafnrauthor']));
  
       $Query = "INSERT INTO example (cafnrcontent,cafnrimage,cafnrstart_date,cafnrend_date,cafnrauthor) VALUES('$cafnrcontent','$cafnrimage','$cafnrstart_date','$cafnrend_date','$cafnrauthor')";
  
      $run = mysqli_query($DBcon, $Query);
               if (!$run) {
                  echo 'Query Failed ';
              }
            }
  </code></pre>
  
  <p>Can anyone show me an example? Please help me. Thanks in advance :)</p>