Jump to content
xisto Community
Sign in to follow this  
Blessed

[php] Header Function

Recommended Posts

 Header function

 

Greetings

 

we are going to use the header() funtion to redirect

 

start making a file called page.php

 

at the top of the file add

<?php?>

Example 1

After <?php add

 

header('Location: http://trap17.com;;

the LOCATION means

where you want it to go.

 

Example 2

you also can define a file that you want to redirect to

After <?php add

 

header('Location: index.php');

Example 3

you also can add a timer to it :)

After <?php add

 

header('Refresh: 0; url=http://trap17.com; );

Refresh: 0; means that it will refresh to the url you entered and

the 0; means the seconds it wait to refresh.

 

Example 4

now if you want to go to the root of the site use this ;)

After <?php add

 

header('Refresh: 3; url=/');

Have fun with this tutorial.. ;)

Edited by Blessed (see edit history)

Share this post


Link to post
Share on other sites

Hey, nice bit of info there, i never knew you could add a timer to the redirect thingy, that could be very useful. Its worth mentioning that any HEADER function wont work if there is output before it. Eg if you used ECHO or PRINT before using the HEADER it will give an error, i think you can d ther things like form processing, database connections etc but nothing can be output to the browser before the HEADER, that caused me some headaches in the past.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.