Jump to content

header not working


gotornot

Recommended Posts

Hi

 

I am trying to use a header redirect AFTER html output which is obviously not going to work.

I want to run a script in the background get a return code ie a 1 or 0 from the page that data is submitted to then after send the user on to the next step

 

i cant seem to get it to work any ideas

 

// now we must send the data that is collected to the url

ob_start();

ignore_user_abort(true);

set_time_limit(5); // MAXIMUM RUNNING TIME CAN BE SET TO WHATEVER IN SECONDS I BELIVE

//THE HTML BELOW CAN BE CHANGED.

echo '<img src="waitani.gif" width="250" height="250">';

 

echo str_repeat("<!-- Flush that stuff --->\n", 256);

 

header('Connection: close');

header("Content-length: ".ob_get_length());

 

ob_end_flush(); // fly my pretties!

flush(); // browser should now stop rolling

//ANDY WHATEVER YOU WANT TO HERE.

#header('Location:'.$final_url);

$handle = fopen("$final_url", "r");

$contents2 = fread($handle, 1);

if ($contents2=="1")

{

$test = "1 seen and read";

}else{

$test = "Nothing seen im broke";

}

//now send to a url + $test

exit();

 

Link to comment
https://forums.phpfreaks.com/topic/194894-header-not-working/
Share on other sites

Re-order your code. There is no reason whatsoever to have a redirect AFTER output code. Since if you are being redirected you will not see any code that is output, what's the point in outputting it. Move logic to the top of the script and only output afterwards.

Link to comment
https://forums.phpfreaks.com/topic/194894-header-not-working/#findComment-1024738
Share on other sites

there is an awfull lot more of outputted code above this that handles the data popping it into data bases etc . the bit ive shown is where it contacts a script on another server irrespective of wether the user closes the window and processes that data

 

i just wondered how the best way to move to the next stage

Link to comment
https://forums.phpfreaks.com/topic/194894-header-not-working/#findComment-1024741
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.