-1

I am setting a parameters in my PHP page and need to pass it to another WEB SITE, to execute operation on the WEB SITE (i don't need to get re result). I use header ("location : https://localhost/test=123") but its not executing it and display:

Warning: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/script1.php:33) in /Applications/XAMPP/xamppfiles/htdocs/script1.php on line 106

How can i simply just invoke it one time?

if there is solution from bash file,also can help...

Oleg
  • 381
  • 1
  • 5
  • 15
  • possible duplicate of [Warning: Cannot modify header information - headers already sent by](http://stackoverflow.com/questions/506155/warning-cannot-modify-header-information-headers-already-sent-by) and [oh so very many others](https://www.google.co.uk/search?sugexp=chrome,mod=8&sourceid=chrome&ie=UTF-8&q=site%3Astackoverflow.com+Cannot+modify+header+information+-+headers+already+sent) – Quentin Jun 07 '12 at 13:48

3 Answers3

2

The header function can only be used before ANY output is displayed on the screen.
For example:

 <?php
    echo( 'test' );
    header('location: www.google.com');
 ?>

Would fail with that error you reported.

Ben Poulson
  • 3,368
  • 2
  • 17
  • 26
  • thanks, i cancel all the `echo` and its worked! Can i do it without actually be redirected to that site? – Oleg Jun 07 '12 at 14:03
  • As stated in one of the answers below, file_get_contents() would send a request to the given URL, without redirecting you to the site. – Ben Poulson Jun 07 '12 at 15:04
0

You already output content to use header(). I would recommend:

$sRemotePage = file_get_contents('https://localhost/test=123');

More here: http://php.net/manual/en/function.file-get-contents.php

Fab V.
  • 1,052
  • 12
  • 17
-1

You can use the HTTP meta element to set where the browser redirects the user. It needs to look like this:

<meta HTTP-EQUIV="Refresh" content="0; url=http://localhost/test=123">

Where 0 is the number of seconds the browser will wait before redirecting, and url is the redirected URL.

The other option would be using Output Buffering, but I am not entirely sure what you want to do and whether it can include ob_ or not.

Whisperity
  • 3,012
  • 1
  • 19
  • 36