Two implementations of a PHP sign-up page
Escape the hashed password, don't hash the escaped password.... just hash the pw. 
Prefer prepared statements over escaping.
Break up the logic into functions. 
Please indent better - your formatting is a bit of a mess.
You do not need to use both escaping and prepared statements. Pick one. (Pick prepared statements)




Edit:

In this case, if your IDs are integers, you don't need to escape them or use prepared statements. Just check if they are integers first with is_numeric(). If you know they're integers then you know they're safe.

Generally though, prepared statements are the way to go.