Jump to content

[SOLVED] PHP Sleep() help


shakeit

Recommended Posts

Hello Everyone.

 

I've been sitting for quite a while now, reading the sleep() manual and tried to turn the code upside down and inside out but nothing helps... I want the current page to wait a few seconds before it is directed to another ( after a successfull registration ). So i thought the best way to do that is to use sleep().

 

However, this does work to a certain point ... the current page waits for 5 seconds, but the text I want to show the user in the meantime doesn't show? Why? Without the sleep() and the header() it shows without any problem. Can anyone please help?

 

if( $add_user == 1 )

{

          // This method returns true if the registration is successfull

$check = $min->register($name, $adress, $age, $email, $phone, $country,$city, $newsletter, $uname, $password, $password2 );

 

          if( $check )

          {

                  $name = ""; $adress = ""; $age = ""; $email = ""; $phone = ""; $country = ""; $city = ""; $newsletter = ""; $uname = ""; $password = ""; $password2 = "";

 

                  echo "Successfull registration";      // <-------- THIS STRING DOESN'T SHOW

      sleep(5);

      header("Location: $loginHeader");

          }

}

 

 

 

Link to comment
Share on other sites

sleep() will sleep in the execution of the script thus resulting in the script "hanging" (at least it will look like that to the user). You should simply use a Refresh header instead of a Location header if you wish to delay the redirection.

 

Refresh: 5; url=http://example.com

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.