top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

What are various methods for redirecting a PHP page?

+1 vote
What are various methods for redirecting a PHP page?
posted May 14, 2014 by Sachin Dahda

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

2 Answers

+1 vote
Best answer

After form submission or a page redirect is triggered, it's commonplace to redirect the user to a different page or to the same page, formatted in a different way. Usually, you'd complete this by coding:

header('Location:  destination.php');

This is a completely acceptable way to code your pages, but I prefer to use a redirect function instead. Why? It's much more readable, and quite honestly, I'm tired of writing the header('Location: …') code.

function redirect($url,$permanent = false)
        header('HTTP/1.1 301 Moved Permanently');
    header('Location: '.$url);
answer May 17, 2014 by Vrije Mani Upadhyay
0 votes

You can redirect your PHP page via following methods:

  1. By Using Java script:
    '; echo 'window.location.href="'.$filename.'";'; echo ''; echo ''; echo ''; echo ''; } } redirect('http:// '); ?>

  2. By Using php function: header ("Location: http:// ");

answer May 15, 2014 by Rahul Mahajan
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.