0

i posted delay loading with php but everybody said this is difficult

and it better using jquery.

anyone give me some hint or reference?


i want to make my php page delay loading with some image(loading image)

such like

http://www.businessbee.com/wp-content/uploads/24534/loading_home.gif

i have 3 php page

from first page if click submit button, next page is loading.php page which

display loading image and 30sec later i want to redirect to

third page final.php.

redirection and delay function is no problem , problem is

when start to delay loading image is not showing..

i want loading image show to user while delay 30sec

<?php
$delaytime=30;
for ($x=0; $x<$delaytime; $x++) {
  echo " ";
  sleep(1);
}

header("Location: /final.php"); /* Redirect browser */
exit();

?>
4
  • 1
    I believe the time is in milliseconds. Did you try sleep(1000)? Commented Dec 11, 2014 at 12:19
  • 1
    @g_m sleep is in seconds. usleep is in microseconds. Commented Dec 11, 2014 at 12:20
  • @NiettheDarkAbsol You are right. I stand corrected. Commented Dec 11, 2014 at 12:21
  • this is not milisecond...it second..so it 30second Commented Dec 11, 2014 at 12:25

1 Answer 1

1

Your loading.php page should just be:

<img src="loading_image_here.gif" />
<a href="final.php">Click here if the browser does not redirect you</a>
<script type="text/javascript">
    setTimeout(function() {
        location.href = "final.php";
    },30000); // 30 seconds
</script>

Note that most people probably won't want to wait 30 seconds unless there's a damn good reason...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.