PHP Redirect From One webPage To Another Using header() function

In this PHP tutorial, we discuss PHP redirect that how to redirect from one page to another using PHP.In HTML, we are using hyperlink tag <a> which is used to redirect from one page to another page but there is a condition on it, That you need to click on a  link tag. But in PHP, we are going to redirect from one page to another page.

Let see, there is a function in PHP which is used for redirection called header() function.

php redirect

PHP Redirect using header() function

Now we create an example for it so we can understand better.we are going to create a login form and when we get the result we move to another page.

Login Form in Html:

Below code contains two input and one submit button. Two input are for username and password.

CSS Designing For Login Form:

Next Step using CSS to design a login form so it looks better.

PHP Script:

Now PHP script for fetching post variables when we submit the form.

Complete Code:

And here is a complete code to test the header() function.


This is all you need to redirect to another page using PHP.I hope you like this post. If you have any query related to this post.Feel free comment on the comment box.Do not forget to share this post because someone else also needs this post. And don’t forget to like on Facebook Page.


Also Read:

  1.  PHP Tutorial – PHP Introduction
  2.  PHP Echo And Print Function
  3.  PHP Explode And Implode Function

Leave a Reply

Your email address will not be published. Required fields are marked *