Results 1 to 6 of 6

Thread: Refresh or Reload page

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Refresh or Reload page

    Hi,

    My question is how do i reload a php page after a job has been done.

    Fore example my script does :

    work 1

    work 2

    and after work 2 is finished i would like to reload the same xy.php page.

    Can it be done ?


    Cheers and Thanks!
    Thanks for helping me out.

  2. #2
    Addicted Member
    Join Date
    Feb 2010
    Location
    Damascus - Syria
    Posts
    145

    Re: Refresh or Reload page

    Hello

    here is a simple way:

    PHP Code:
    <?php
    if ($_GET['job'] != 'done') {
        
    // work 1
        // work 2
        
    header('Location: xy.php?job=done');
        exit();
    } else {
        
    // do another thing
    }
    ?>
    regards

    Feras Jobeir
    Last edited by fjober; Jul 28th, 2011 at 10:14 AM.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: Refresh or Reload page

    thank you very much!

    i will try the code now ...

    EDIT:

    this is what i have :

    echo "<textarea rows=20 cols=40>" . $messageToShow."</textarea>";
    die("Elaborated.");

    $stop++;
    header('Location: cronindex.php?');
    exit();


    But this seems not to work...maybe i did something wrong?
    Last edited by batori; Jul 28th, 2011 at 10:46 AM.
    Thanks for helping me out.

  4. #4
    Addicted Member
    Join Date
    Feb 2010
    Location
    Damascus - Syria
    Posts
    145

    Re: Refresh or Reload page

    hello

    - In my example, to know that we have done work1 and work2, I have passed a variable (job) with the value (done), in the URL.

    - when you reload the page, all variable will be (cleaned from memory), you have to pass them via URL, store them in a session or database or any other way to work with them later

    regards

    Feras Jobeir

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: Refresh or Reload page

    Is there a way to just reload the page ...

    I have read that header function will not work is a text has been echoed before ....

    Im really having trouble making this work ....
    Thanks for helping me out.

  6. #6
    Addicted Member
    Join Date
    Feb 2010
    Location
    Damascus - Syria
    Posts
    145

    Re: Refresh or Reload page

    Hello

    so, instead of using header, try meta refresh like this

    PHP Code:
    echo '<meta http-equiv="refresh" content="0; URL=xy.php?job=done" />'
    but it may be disabled, so try another way using javascript:

    PHP Code:
    echo '<script type="text/javascript">window.location="xy.php?job=done"</script>'
    regards

    Feras Jobeir

Posting Permissions

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



Click Here to Expand Forum to Full Width