10

Possible Duplicate:
PHP page redirect

how do i redirect to another page in php, once a process is finished.

for example my <form> tag sets the action attribute to "process.php". After the process on process.php is finished i want it to redirect to the site it cam from. how is that done?

Community
  • 1
  • 1
prometheuspk
  • 3,754
  • 11
  • 43
  • 58
  • Dup of [PHP page redirect](http://stackoverflow.com/questions/2112373/php-page-redirect), [How do I navigate to another page when PHP script is done?](http://stackoverflow.com/questions/4643697/how-do-i-navigate-to-another-page-when-php-script-is-done) – outis Oct 23 '11 at 12:00
  • As a general comment: HTTP/1.1 requires an absolute URI as argument to `Location`. – str Oct 23 '11 at 12:22

4 Answers4

24

Use the following code:

if(processing == success) {
  header("Location:filename");
  exit();
}

And you are good to go.

José Miguel
  • 97
  • 2
  • 15
NoPHPknowldege
  • 294
  • 1
  • 10
14
<?php
    header("Location: index.html");
?>

Just make sure nothing is actually written to the page prior to this code, or it won't work.

Sven
  • 178
  • 1
  • 8
3

Use something like header( 'Location: /my-other-page.html' ); to redirect. You can't have sent any other data on the page before you do this though.

orangething
  • 708
  • 5
  • 16
2
header( 'Location: http://www.yoursite.com/new_page.html' );

in your process.php file

Kamil Lach
  • 4,519
  • 2
  • 19
  • 20