To get the refferer
$_SERVER['HTTP_REFERER'];
from here http://php.net/manual/en/reserved.variables.server.php
For your question, i think you need to store some data in $_SESSION.
For example, $_SESSION['flash-message'] = 'Registration done successefull!'
;