All TalkersCode Topics

Follow TalkersCode On Social Media - A Social Media Network for developers Join Now ➔

PHP Redirect Without Header

Last Updated : Mar 11, 2024

PHP Redirect Without Header

In this tutorial we will show you the solution of PHP redirect without header, redirect is very useful in today’s time to navigate from one page to another inside a website.

So, let us understand our today’s article without using header.

Step By Step Guide On PHP Redirect Without Header :-

As, there are many ways with help of which we are able to redirect in php.

One of the most famous or say most used method is header method.

But in today’s article we are going to understand another way of redirection without using header tag. Now, let us see our new method.

<!DOCTYPE html>
          <title> php tutorials </title>
// php code here
<script type="text/javascript"> window.location.rel="noopener" target="_blank" href = '';
 // another way
 <script type="text/javascript">
window.location.href = '';
//rest php code here
  1. First, we write <! DOCTYPE html> which we used as an instruction to the web browser about what version of HTML file is written in.
  2. Secondly, the <html> tag is used to indicate the beginning of an HTML document.
  3. As above now <head> tag is used to contain information about web page. In this tag a <title> tag is used which helps us to specify a webpage title. Both <head> and <title> tags are Paired tags. So, both have </head> and </title> ending tags respectively.
  4. Here, then we create a body tag. All the content which we want to show on browser’s screen or display is always written inside this codes.
  5. Here, inside body as we can see that we create a basic php tag or say structure for php to write codes inside that.
  6. Now, after this for redirect we are going to use some JavaScript code there. For this we are going to use script tag. A script tag is always a paired tag and it must have a closing tag. Our all JavaScript code is written under these tags.
  7. Here, we use window.location.href attribute. This is another method of redirection in JavaScript. For this we use this and give the website link/ name inside the value of this attribute. This helps us for redirection.
  8. Whereas in another way we use the same attribute but in different way. For this we first use window.location and give it value and after this we use href attribute and inside this we give the value of website where we want to redirect.
  9. As we see there is one more attribute that is target. Here, we have to give value of the website where we want it to open like in same tab, in next or say blank tab, etc.
  10. At last, the <body> and <html> tags are closed with </body> and </html> respectively.

Conclusion :-

At last in conclusion, here we can say that with the help of this article we are able to understand how to redirect in php without using header.

I hope this tutorial on PHP redirect without header helps you and the steps and method mentioned above are easy to follow and implement.