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";
}
Frozen
  • 87
  • 1
  • 4
  • 15
  • umm... PHP? JavaScript? Looks like you are mixing languages here... – Lix May 11 '14 at 12:39
  • If you want to wait using javascript, check this: http://stackoverflow.com/questions/951021/what-do-i-do-if-i-want-a-javascript-version-of-sleep – Oli May 11 '14 at 12:41

2 Answers2

4

You can try:

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

2 = number of seconds; url = adress

manxten
  • 77
  • 2
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.

Niet the Dark Absol
  • 301,028
  • 70
  • 427
  • 540