I created some PHP code where I collect data from another server. I confirmed the data is ok with a bunch of print statements like:
print "<br /><br />headline: " . $user->headline ;
print "<br /><br />industry: " . $user->industry ;
That all works fine. But instead of using print to show the contents, I want to redirect to another URL on a different server and send that info over. So I commented out the print lines and instead created a set of query parameters and used the header function to try to redirect, as follows:
$params = '?success=ok&uname=' . $_SESSION['uname'] . '&odistate=' . $_SESSION['odistate'];
$params .= '&firstName=' . $user->firstName . '&lastName=' . $user->lastName . '&headline=' . $user->headline . '&industry=' . $user->industry;
$params .= '&summary=' . $user->summary . '&publicProfleUrl=' . $user->publicProfileUrl . '&emailAddress=' . $user->emailAddress;
$params .= '&numRecommenders=' . $user->numRecommenders;
$url = 'http://www.example.org/profileInfo/' . $params;
header("location: $url");
exit;
Nothing happens though. I can go to the page, but the redirection doesn't take place. I know there should be no source prior to the redirect, and I check the source and it is empty. There are no errors in the PHP log. The code was checked for syntax errors and there are none.
If I comment out the redirect section and use the print statements instead, it works fine. But if I comment out the print statements and try to use the redirect section instead nothing happens. Just a blank screen.
If I slip a
print $url;
in just before the header() call naturally it won't redirect then, but I can confirm that the URL appears to be properly formed. There are some spaces in some of the query values though. Could it be that it has to be URL encoded to turn the spaces into %20 or some problem like that?
What might cause the redirect to just not happen?