Headers must be output to the browser before outputting any text. If you output text first, you've lost your opportunity to send headers because the body of the page must always be output last.
If you wish to redirect the browser after displaying some text, you'll need to utilize either Javascript, or a META redirect:
Javascript
<script type="text/javascript">
setTimeout(function() {
window.location = 'usermainpage.php';
}, 2000);
</script>
Replace the value 2000 with the number of milliseconds to wait before re-direct. 2000 = 2 seconds, 10000 = 10 seconds.
META Tag
<meta http-equiv="refresh" content="5; URL='usermainpage.php'">
Set the number 5
to the number of seconds to wait before re-directing.