In PHP, you can redirect a URL to another by calling a simple function header(). e.g. write the following php code to redirect the user from one page to another.
- Code: Select all
header("Location: you_url_or_page_name");
exit( ); // write this to stop the execution of the page from this onward
This code will works fine in your PHP script if you havn't output any data to the browser yet. If you are not sure then please write the below line at the top of your php script.
- Code: Select all
ob_start( );
This function don't output any data to the browser until the script is fully executed. If you don't use this function and have output some data event any single character, then you will get the "Headers already sent" like error from the header() function.