0

I wish after echo can wait about 2 second then move to another page ? how to do that ? using jquery ?

if($theme_added)
{
  echo "Theme has been successfully added.";
  window.location.href="manage_party_info.php";
}
2
  • umm... PHP? JavaScript? Looks like you are mixing languages here... Commented May 11, 2014 at 12:39
  • If you want to wait using javascript, check this: stackoverflow.com/questions/951021/… Commented May 11, 2014 at 12:41

2 Answers 2

3

You can try:

header('refresh: 2; url=http://www.example.net');

2 = number of seconds; url = adress

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

5 Comments

Sorry, 40 seconds too slow ;)
this is it, maybe next time:)
Are you challenging "The Sniper"? :p
why not? i'm a cheetah :D
Hmmm... Cheetahs can reach 60 miles per hour. Sniper bullets average around 500 metres per second (~1,120 miles per hour). Might need to attach some rockets to your cheetah :p
0

For an instant redirect, you would do header("Location: manage_party_info.ph");

For a delayed one, however, you can output some JavaScript, or use a "meta refresh":

header("Refresh: 3; url=manage_party_info.php");
die("<p>Theme has been successfully added.</p>"
    ."<p>You will be redirected. Please <a href=\"manage_party_info.php\">click here</a> if this page appears for more than five seconds.</p>");

Notice how I added a manual alternative with the link. This is an essential usability thing, because some users may have disabled the Refresh header in their browser (as it can be and sometimes is used for malicious purposes). You will face this problem if you use JavaScript/jQuery too, because users can disable JS.

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.