To prevent the player standing up inside a wall do something like:
If the player is crawling and down is not pressed then
change the player size to (39,126)
if the player is not overlapping wall at offset 0,-1 then
stand up... set animations etc..
else
set size back to (39,126) + stay crouching