Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,743
    Thanks
    82
    Thanked 110 Times in 109 Posts

    Alternative to sleep

    I want to echo "Logging In..." for 3 seconds before redirecting (header) the script to the next page. Is that possible?
    I tried using sleep(3); but it freezes before the echo and then quickly redirects and never shows the echo.

    Thanks
    Last edited by myfayt; 05-04-2014 at 10:00 PM.
    Been a sign maker for 8 years. My business:
    American Made Signs

  2. #2
    Regular Coder
    Join Date
    Sep 2011
    Posts
    453
    Thanks
    18
    Thanked 27 Times in 27 Posts
    This will require javascript, not PHP. If you are using a form post (page refreshes), then add a javascript command to refresh or redirect after a certain amount of time. If you are using jQuery, just add the refresh or redirect in the success handler (when data is returned) to pause on a good login and then redirect.

    PHP executes and then sends the data to the browser. You can't output a page to a browser and then redirect it with PHP, because either the script will keep running and slow both the page and server or the page will be a delayed load and redirect immediately.

  3. Users who have thanked Dubz for this post:

    myfayt (05-04-2014)

  4. #3
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,743
    Thanks
    82
    Thanked 110 Times in 109 Posts
    Thanks Dubz
    Been a sign maker for 8 years. My business:
    American Made Signs


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •