Update flashmessage.php

Redesigned code for better handling