1. Using header function with
exit()
<?php
header('Location: target-page.php');
exit();
?>
but if you use header function then some times you will get "warning
like header already send" to resolve that do not echo or print before sending headers or you can simply use die()
or exit()
after header function.
2. Without header
<?php
echo "<script>location.href='target-page.php';</script>";
?>
here you will not face any problem
3. Using header function with
ob_start()
andob_end_flush()
<?php
ob_start(); //this should be first line of your page
header('Location: target-page.php');
ob_end_flush(); //this should be last line of your page
?>