You can't redirect to a file after output has been shown. You have two alternate solutions here:
Refresh the page after a timeout while showing the message in the meantime, using a
<meta>
tag:<meta http-equiv="refresh" content="5; url=../login.php">
Output the message after redirection:
<?php header('Location: ../login.php?registered=true');
And in login.php:
<?php if (@$_GET['registered'] == 'true') echo 'You have registered successfully.'