I am trying to update a record in database, but I get this error Notice: Undefined variable: id in C:\xampp\htdocs\test\admin\admin\update.php on line 15 have tried the POST AND GET method but still get the error. 
Here is my code:
<?php
session_start();
//Include database connection details
include('dbconnect.php');
{   
    if(isset($_GET['id']))
        $id = mysqli_real_escape_string($_POST['id']);  
    $title =  ($_POST['title']);
    //$cname = ($_POST['txtEditor']);
    //$cat = strip_tags($_POST['cat']);
    //$date=date("Y-m-d");
    $sql =("UPDATE newsarticles SET  headline='$title'  WHERE ID='$id'");
    if ($conn->query($sql) === TRUE) {
        echo "Record updated successfully";
    } else {
        echo "Error updating record: " . $conn->error;
    }
}
$conn->close();
//$results = $mysqli->query("UPDATE products SET product_name='52 inch TV', product_code='323343' WHERE ID=24");
?>
here is my form
  <?php
session_start();
include("dbconnect.php");
 if(isset($_GET['id']))
    $id = strip_tags($_GET['id']);
$sql = "SELECT * FROM newsarticles WHERE id=$id" ;
$result = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_assoc($result))
    {
        $image= $row['photo'];
    $title = $row['headline'];
    $description = ( $row['text']);
    $time = $row['publishDate'];
    }
?>
<link href="plugins/WYSIWYG/editor.css" type="text/css" rel="stylesheet"/>
<script src="plugins/WYSIWYG/editor.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#txtEditor").Editor();
        $("#txtEditor").Editor("setText", <?php echo json_encode($description) ;?>);
    });
    </script>
<form name="my_form" action="update.php" method="POST"  enctype="multipart/form-data">
  <div class="form-group">
    <label for="exampleInputEmail1">Date</label>
    <input type="text" class="form-control" id="time" name="time"  value="<?php echo date('d-m-Y'); ?>" disabled>
    <small id="emailHelp" class="form-text text-muted"></small>
  </div>
  <div class="form-group">
    <label>Article Title</label>
    <input type="text" class="form-control" id="title" name="title" value="<?php echo $title; ?>" placeholder="title" required />
  </div>
  <div class="form-group">
    <label >select categories</label>
    <select class="form-control" id="cat" name="cat">
      <option value="World">World</option>
 <option value="Sport">Sport</option>
 <option value="Politics">Politics</option>
 <option value="Business">Business</option>
 <option value="Technology">Technology</option>
 <option value="Entertainment">Entertainment</option>
 <option value="Fashion">Fashion</option>
 <option value="Gist">Gist</option>    </select>
  </div>
  <div class="form-group">
    <label>Write Article </label>
    <textarea class="form-control" id="txtEditor" name="txtEditor"></textarea>
  </div>
  <div class="form-group">
    <label for="exampleInputFile">upload image</label>
    <input type="file" accept="image/*" name="myimage" id="myimage" class="form-control-file" id="exampleInputFile" aria-describedby="fileHelp">
    <small id="fileHelp" class="form-text text-muted"></small>
  </div>
  <button onclick=" $('#txtEditor').val($('.Editor-editor').html());" type="Publish" id="Publish" name="Publish" class="btn btn-primary">Publish</button>
</form>
the above code is my form page with php code to display value from database on their respective field
Please any help?
 
    