Redirect and Refresh

Redirect and Refresh

For redirecting a page we use a simple command header().
the command header can be used in two ways to redirect a web page

one is redirecting using location, another one is refresh

1 . Example of header(”Location: ..)

<?php

header(”Location: http://www.php.net”);

?>

the above code will redirect you to php.net immediately on reaching the header
command and the constraint is nothing should be outputted before using header().

2 . Example of header(”refresh: ..)

<?php

header( ‘refresh: 5; url=http://www.youdomain.com/welcomeuser.php’ );
echo ‘Your content are successfully registered’;

?>

the above code will output the content below header() and then refresh or
redirect the page after 5 seconds

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.