Redirect when script is complete?

Discussion in 'PHP' started by timallard, Aug 21, 2009.

  1. #1
    I am trying to redirect to a new page once a script is done throwing csv data into a db...it roughly takes about 15 seconds to do so. Once that import is complete. I want it to redirect to a completion page...


    any ideas on how to do this?

    Thank you!!
     
    timallard, Aug 21, 2009 IP
  2. Pixel T.

    Pixel T. Well-Known Member

    Messages:
    1,205
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    170
    #2
    Try this bro.

     
    Pixel T., Aug 21, 2009 IP
  3. timallard

    timallard Well-Known Member

    Messages:
    1,634
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    158
    #3
    But his there a way to have it redirect after the script finishes its job?.. dynamically?

    script start
    parsing parsing parsing parsing
    script complete
    redirect
     
    timallard, Aug 21, 2009 IP
  4. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Assuming you have not yet output anything:

    
    header('Location: http://bla.com');
    die();
    
    PHP:
     
    premiumscripts, Aug 21, 2009 IP
  5. Goramba

    Goramba Peon

    Messages:
    128
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You can use javascript. Put this at the bottom of the script:

    echo "<script language=javascript> setTimeout(\"location.href='index.php'\", 0) </script>";
    PHP:
     
    Goramba, Aug 21, 2009 IP
  6. Ultimate_coder

    Ultimate_coder Peon

    Messages:
    43
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    use header rederiction followed by a 15 seconds leep time

    sleep(15);
    header("location: hello.html");
     
    Ultimate_coder, Aug 21, 2009 IP
  7. bulkemailpp

    bulkemailpp Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    That's the right way, use this. If you have yet output anything, use output buffering.
     
    bulkemailpp, Aug 24, 2009 IP
  8. Sam Designs

    Sam Designs Active Member

    Messages:
    474
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #8
    Slightly different to premiumscripts, if you want to direct to a page on your website:

    header("Location: index.php");
    die();
     
    Sam Designs, Aug 24, 2009 IP
  9. bulkemailpp

    bulkemailpp Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I'm not sure it's a good idea, see the PHP manual pages:

    Note: HTTP/1.1 requires an absolute URI as argument to » Location: including the scheme, hostname and absolute path, but some clients accept relative URIs.
     
    bulkemailpp, Aug 24, 2009 IP