header location and redirect

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bob Bedford

    header location and redirect

    From my record insertion page I do, in some cases, this:

    header("Locatio n: http://$SERVER_NAME/mainpage.php?SI D");

    problem is that the mainpage.php doesn't takes new datas. I've to refresh
    the page to see the new inserted record.

    doing this:
    header("Refresh : 0; URL=http://".$_SERVER['HTTP_HOST']."/mainpage.php?SI D);

    isn't considered a good alternative.
    I want to redirect to the mainpage.php with refreshed datas.

    How to do so ? may I keep Refresh header command or it will not work on some
    browser ?

    Bob


  • Tim Van Wassenhove

    #2
    Re: header location and redirect

    On 2005-08-25, Bob Bedford <bedford1@notfo rspammershotmai l.com> wrote:[color=blue]
    > From my record insertion page I do, in some cases, this:
    >
    > header("Locatio n: http://$SERVER_NAME/mainpage.php?SI D");
    >
    > problem is that the mainpage.php doesn't takes new datas. I've to refresh
    > the page to see the new inserted record.[/color]

    What is going on in mainpage.php? Are you sure the record insertion page
    really does what you expect? Checked for errors??

    If you start your scripts with the code below, you usually get some
    hints ;)

    ini_set('error_ reporting', E_ALL);
    ini_set('displa y_errors', TRUE);

    --
    Met vriendelijke groeten,
    Tim Van Wassenhove <http://timvw.madoka.be >

    Comment

    • Alvaro G Vicario

      #3
      Re: header location and redirect

      *** Bob Bedford wrote/escribió (Thu, 25 Aug 2005 18:48:08 +0200):[color=blue]
      > I want to redirect to the mainpage.php with refreshed datas.
      >
      > How to do so ? may I keep Refresh header command or it will not work on some
      > browser ?[/color]

      That's the default setting for most PHP installs: to tell the browser not
      to cache the page. Though I don't think that's the problem, you can play
      around with this headers in mainpage.php:


      header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()-86400*365*10) . ' GMT');
      header('Expires : ' . gmdate('D, d M Y H:i:s', time()-86400*365*10) . ' GMT');


      // HTTP/1.1
      header('Cache-Control: no-store, no-cache, must-revalidate');
      header('Cache-Control: post-check=0, pre-check=0', FALSE);

      // HTTP/1.0
      header('Pragma: no-cache');


      BTW, be aware that whatever comes after header() is also executed unless you exit().

      --
      -- Álvaro G. Vicario - Burgos, Spain
      -- http://bits.demogracia.com - Mi sitio sobre programación web
      -- Don't e-mail me your questions, post them to the group
      --

      Comment

      • Bob Bedford

        #4
        Re: header location and redirect

        thanks for your help.
        [color=blue]
        > What is going on in mainpage.php? Are you sure the record insertion page
        > really does what you expect? Checked for errors??[/color]
        mainpage.php does show the list of inserted records for a registered user.
        The record is actually inserted for sure, as when I do a refresh, then the
        new record is there.
        [color=blue]
        >
        > If you start your scripts with the code below, you usually get some
        > hints ;)
        >
        > ini_set('error_ reporting', E_ALL);
        > ini_set('displa y_errors', TRUE);[/color]


        Comment

        Working...