1

I would like to redirect my user to a new page, but the current site continues to run a script that sends a threaded message 10 minutes later at a specified address. I tried something like this:

Header('Location: xy.com');
sleep(100);
do_the_email_sending_here();

But actually it doesn't worked,because the site waited for 100sec, so the site is not immediately redirected me. Any idea how can i solve this? Any idea for while() or for() loop?

szebasztian
  • 171
  • 3
  • 14
  • just because you issued a header() call doesn't mean the client is going to magically start going there. it MAY go there, but isn't required to until the rest of your script finishes. sleep(100) would wait for 100 seconds, anyways. you should probably use a job scheduler, e.g. `at` to schedule a job +10 minutes in the future to the the email sending, rather than hoping the user won't hit escape and cause your script to get shut down. – Marc B Jun 17 '15 at 15:15
  • i don't think you can do this no more.. you use to be able to flush the buffer, but I think you can't send partials anymore or rather, modern browsers won't display partials.. but i could be wrong.. – Keith A Jun 17 '15 at 15:16
  • I'll try to ask the question a different way.There are 3 pages. A want redirect the user from the "A" site to the "B" site, and than from the "B" site to the "C" site. If the user leave the "B" site or something happen with the internet connection, and he cant reach the C site, than i want send an email. something like this "oh look stoped". Any other solution can be good. – szebasztian Jun 18 '15 at 08:46

2 Answers2

0

Try this:

         Header("Refresh: 600;", "Location: xy.com");
         do_the_email_sending_here();

The Refresh: 600; will preform your header in 600 seconds or 10 minutes.

brandon Whe
  • 206
  • 1
  • 14
0

Solution for the problem: Cron Job , Good learning.

szebasztian
  • 171
  • 3
  • 14