Get Post ID in Admin Edit screen otherwise generate it?

While clicking ADD-NEW (i mean when creating new post), it has already assigned an ID. You can catch it using javascript,like:

if(document.getElementById("postID")){
   alert(document.getElementById("postID"));
}

or catch it using PHP:

var_dump($GLOBALS);

and see the variable name

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)