skip to Main Content

my code:-

$host = "https://example.org/get.php?";
$newurl = file_get_contents($url);
$newurl = substr($newurl,stripos($newurl,"who"));
$newurl = substr($newurl,0,stripos($newurl,"</"));
// newurl string starts with "who" and ends with "</"
//var_dump($host.$newurl)."<br>";  //shows correct request string
header("Location: " . $host.$newurl);
exit(); 

new window displays the correct url request in the address bar but isn’t redrawn
page source is blank except a single "1" char.
on pressing the resubmit button the page is drawn correctly.
Any help greatly appreciated.

Stve

2

Answers


  1. Chosen as BEST ANSWER

    Firstly - If other people have a similar problem I would urge them to check that what they think is being offered up to file_get_contents($url) and to header("Location: $host$newurl"); is correct. Not is my case.

    Is this case the PHP was interfacing with my java server which it did in two ways the file_get_contents($url); updated the database and returned a new url. Then the header("Location: $host$newurl"); showed the updated page.

    Secondly - make sure the server is doing what you expect. In this case the server had closed the socket after the file_get_contents($url); so could not respond to the header("Location: $host$newurl");

    Even old hands fall into the trap of believing their code is correct!

    Thanks all for you reponses.

    Steve


  2. You can change the file_get_contents($url); to $host because it’s not correct source url

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search