www.webdeveloper.com
Results 1 to 7 of 7

Thread: Page doesn't reload after redirect. Please help

  1. #1
    Join Date
    Jun 2008
    Posts
    207

    Page doesn't reload after redirect. Please help

    Hi, I have a PHP page that displays a table of records, pulled from a MySQL database.

    Each record has a delete link that directs to another PHP page that runs the code to delete that record from the DB. It then redirects back to the original page with the table.

    My problem is that the page then needs to be manually refreshed to show that the record has been deleted. It seems it's just displaying the cached version rather than reloading the page.

    Does anyone know how I can fix this?

  2. #2
    Join Date
    Dec 2005
    Posts
    2,984
    Hmmm...maybe this will help:

    http://ca3.php.net/header

    Scroll down to the part on caching directives.

  3. #3
    Join Date
    Jun 2008
    Posts
    207
    I'm affraid i can't really use that thread to help me with my problem. All i want is to be able to redirect to another page and make sure that that page loads from fresh rather than cache. Surely there is a simple function... ?

    Any help would be greatly appreciated.

  4. #4
    Join Date
    Jul 2007
    Location
    Wisconsin
    Posts
    468
    Quote Originally Posted by coldscooter View Post
    I'm affraid i can't really use that thread to help me with my problem. All i want is to be able to redirect to another page and make sure that that page loads from fresh rather than cache. Surely there is a simple function... ?

    Any help would be greatly appreciated.
    I'm sorry, but I think that's exactly what you need.

    PHP Code:
    Example #2 Caching directives

    PHP scripts often generate dynamic content that must not be cached by the client browser 
    or any proxy caches between the server and the client browser. 
    Many proxies and clients can be forced to disable caching with:

    <?php
    // add this to the top of your page with the database records
    header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
    ?>

  5. #5
    Join Date
    Jun 2008
    Posts
    207
    Hi, Sorry i didn't mean to sound ungrateful for the help. But this code does not redirect anywhere. Would i just add: header("location:http:www.test.com"); under these statements?

  6. #6
    Join Date
    Jul 2007
    Location
    Wisconsin
    Posts
    468
    What is the script doing to delete the record?

    Each record has a delete link that directs to another PHP page that runs the code to delete that record from the DB. It then redirects back to the original page with the table.
    The Cache-control goes on the "original" page to force the content to reload on every page load.

  7. #7
    Join Date
    Jun 2008
    Posts
    207
    Excellent. Thanks for your help. That worked a treat.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles