if there is no id in url I want to get the id from database and then redirect to the same page using the id
if(!isset($_GET['id'])){
    $st = $db->query("select id from video where ind = 0 limit 1");
    $st->execute();
    $id = $st->fetchColumn();
    header('location: index.php?id='.$id);
}
$urid = $_GET['id']; // line 15
everything works, page is redirected and id is there but the system creates an error.log file saying:
Undefined array key "id" ... on line 15
so why the system creates this error
redirection should happens before line 15
 
    