top of page

1. Using header function with exit()

<?php header('Location: target-page.php'); exit(); ?>

but if you use header function then some times you will get "warning like header already send" to resolve that do not echo or print before sending headers or you can simply use die() or exit() after header function.

.

2. Without header

<?php echo "<script>location.href='target-page.php';</script>"; ?>

here you will not face any problem

3. Using header function with ob_start() and ob_end_flush()

ob_start(); //this should be first line of your page header('Location: target-page.php'); ob_end_flush(); //this should be last line of your page

​

​

edited Oct 31 '17 at 12:53

answered Apr 13 '17 at 12:44

 

Juned Ansari

1,30011530

​

or

  1. <?php

  2. <?php

  3. $postdata = http_build_query(

  4.    array(

  5.       'var1' => 'du contenu',

  6.       'var2' => 'doh'

  7.    )

  8. );

  9. $opts = array('http' =>

  10.    array(

  11.       'method'  => 'POST',

  12.       'header'  => 'Content-type: application/x-www-form-urlencoded',

  13.       'content' => $postdata

  14.    )

  15. );

  16. $context  = stream_context_create($opts);

  17. $result = file_get_contents('http://example.com/submit.php', false, $context);

  18. ?>

​

Tracker

PHP site support

bottom of page