The PHP header() function send the raw HTTP headers request to the browser. In PHP you can used the header function for redirect the user to another location. The Header code must be place at the very top of the page to prevent any other part of the page from loading. The redirect location is specified by the Location attribute. After the Header function exit() function must be be used to stop further processing on the rest of the code.
Syntax:
header('Location: url);
For Example :
header("Location: http://www.learninghints.com/index.php"); /* Redirect browser */ exit; /* Make sure that code below does not get executed when we redirect. */ ?>
You can also pass the some value through the header function
header("location:url?variable=value);
for example
header("location:test.php?id=101");
Note:- if you are passing the long text then must use urlencode() , perhaps in combination with htmlentities(), these two function will be discussed other Tutorials.
Variables in PHP
PHP Concatenation
Calculation in PHP
If Statements in PHP
if ... else Statements in PHP
Nested IF Structure in PHP
PHP Comparison Operators
Switch Statement in PHP
Logical Operators In PHP
PHP Booleans
FOR Loop in PHP
While Loop In PHP
foreach Loop In PHP
Break Statement
Array In PHP
Associative Array
The Count function
Changing Case Function
Trim Function In PHP
Str_shuffle( ) function
strpos function in PHP
Explode() Function in PHP
Function
Passing Function Arguments
Server Variables
Header Function
Include Function
The require Function